Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. # Coding for Everyone Week 8 homework
  2.  
  3. ## Homework problem 1
  4.  
  5. Given a list of emails you received (list of dictionaries), find all the persons that emailed you with urgent emails. An urgent email is an email that has URGENT in the subject. An email is formed from an author, a subject and content.
  6.  
  7. Example:
  8.  
  9. Given:
  10. emails = [
  11. {
  12. 'author': 'emil@booking.com',
  13. 'subject': 'URGENT: you better do your homework!',
  14. 'content': 'New session is coming, please get the homework ready so we can do amazing stuff!'
  15. },
  16. {
  17. 'author': 'tian@booking.com',
  18. 'subject': 'News',
  19. 'content': 'I am going to take over Emil\'s class next week. Be sure to be there!'
  20. },
  21. {
  22. 'author': 'staff@booking.com',
  23. 'subject': 'URGENT - change your password now!',
  24. 'content': 'Your password has expired, change your password now!!!'
  25. },
  26. {
  27. 'author': 'workbook@booking.com',
  28. 'subject': '[EXTERNAL]Whatever news have been posted...',
  29. 'content': 'X has done Y Urgent thing on platform Z, hooray!'
  30. }
  31. ]
  32. Answer: ['emil@booking.com', 'staff@booking.com']
  33.  
  34. ```
  35. emails = [
  36. {
  37. 'author': 'emil@booking.com',
  38. 'subject': 'URGENT: you better do your homework!',
  39. 'content': 'New session is coming, please get the homework ready so we can do amazing stuff!'
  40. },
  41. {
  42. 'author': 'tian@booking.com',
  43. 'subject': 'News',
  44. 'content': 'I am going to take over Emil\'s class next week. Be sure to be there!'
  45. },
  46. {
  47. 'author': 'staff@booking.com',
  48. 'subject': 'URGENT - change your password now!',
  49. 'content': 'Your password has expired, change your password now!!!'
  50. },
  51. {
  52. 'author': 'workbook@booking.com',
  53. 'subject': '[EXTERNAL]Whatever news have been posted...',
  54. 'content': 'X has done Y Urgent thing on platform Z, hooray!'
  55. }
  56. ]
  57. ```
  58.  
  59. ## Homework problem 2 A
  60.  
  61. Given a string, find all the occurrences of characters in that string.
  62. Print the given counter.
  63.  
  64. Example:
  65.  
  66. Given: 'Emil finally managed to post the homework.'
  67. Answer:
  68. {
  69. 'o': 4,
  70. 'm': 3,
  71. 'l': 3,
  72. 'a': 3,
  73. 'e': 3,
  74. 't': 3,
  75. 'i': 2,
  76. 'n': 2,
  77. 'h': 2,
  78. 'E': 1,
  79. 'f': 1,
  80. 'y': 1,
  81. 'g': 1,
  82. 'd': 1,
  83. 'p': 1,
  84. 's': 1,
  85. 'w': 1,
  86. 'r': 1,
  87. 'k': 1,
  88. }
  89.  
  90. ## Homework problem 2 B
  91.  
  92. Given a string, find the character with the maximum occurrences in that string.
  93. Print the given character.
  94.  
  95. Example:
  96.  
  97. Given: 'Emil finally managed to post the homework.'
  98. Answer: 'o'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement