Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. def first_dictionary():
  2. """
  3. Playing with dictionaries in part 1
  4. """
  5. about_me = { "height" : 12 ,
  6. "color" : "vanta",
  7. "author" : "james"
  8. }
  9. ask_height = input("What is my height. Type height " )
  10. ask_color = input("What is my favorite color. Type color " )
  11. ask_author = input("What is my favorite author. Type author " )
  12.  
  13. if ask_height in about_me:
  14. a = about_me[ask_height]
  15. print("you know it's", a)
  16. b = about_me[ask_color]
  17. print("you know it's", b)
  18. c = about_me[ask_author]
  19. print("you know it's",c)
  20. else:
  21. print("not an option")
  22.  
  23.  
  24.  
  25. first_dictionary()
  26.  
  27.  
  28.  
  29. #create a dictionary mapping your favorite musicians to a list of your favorite songs by them
  30. def second_dictionary():
  31. """
  32.  
  33. create a dictionary mapping your favorite musicians to a list of your favorite songs by them
  34.  
  35. """
  36. bettys_songs = ["germ",1,2,3]
  37. jimmys_songs = ["bacteria",4,5,6]
  38. kims_songs = ["genome", 7,8.1,"nine"]
  39. musicians = {"betty": bettys_songs,
  40. "jimmys": jimmys_songs,
  41. "kims": kims_songs
  42. }
  43. print("Here is my 1st favorite musician and their songs:: ", "betty", musicians["betty"])
  44. print("Here is my 2nd favorite musician and their songs:: ", "jimmys", musicians["jimmys"])
  45. print("Here is my 3rd favorite musician and their songs:: ", "kims", musicians["kims"])
  46.  
  47.  
  48.  
  49.  
  50. second_dictionary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement