Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import random
  2. import pickle
  3. #set up blank list
  4. xmas = []
  5.  
  6. #menu
  7. while True:
  8. print("""What would you like to do with the xmas list...
  9. 1. Add presents and print list
  10. 2. Sort the list into alphabetical order and print list
  11. 3. Pick a random present and print it out
  12. 4. Find out if your list has an i-pad
  13. 5. Print out how many presents are on the list
  14.  
  15. 6. Quit""")
  16.  
  17. #get menu item
  18. choice= input("Please enter your choice ")
  19.  
  20. #output dependent on choices
  21.  
  22. if choice=="1":
  23. print ("Choice 1")
  24. present= input("What is your present? ")
  25. xmas.append(present)
  26. out_file = open("christmas.dat","wb")
  27. pickle.dump(xmas,out_file)
  28. out_file.close()
  29. #Program asking you what is your present, you need to put that present you like
  30.  
  31.  
  32.  
  33. elif choice=="2":
  34. print ("Choice 2" )
  35. xmas.sort()
  36. print(xmas)
  37. #Program sorting evry presents from A to Z
  38.  
  39.  
  40.  
  41.  
  42. elif choice=="3":
  43. print("Choice 3")
  44. print(random.choice(present))
  45. #Program pick random prsesent form your list
  46.  
  47.  
  48.  
  49. elif choice=="4":
  50. print("Choice 4")
  51. if "iPad" in xmas:
  52. print ("Yep")
  53. else:
  54. print("Nah")
  55. #If you choice nuber 4, you asking program about do you have iPad in your present list if not he write nah if yes he write yep
  56.  
  57.  
  58.  
  59. elif choice=="5":
  60. print("Choice 5")
  61. print("You have",len(xmas), "presents")
  62. #When you choice number 5 program will preint how many present do you have from your list
  63.  
  64.  
  65.  
  66.  
  67. elif choice=="6":
  68. print("Choice 6")
  69. break
  70. #When you choice number 6 your program will finish working and close
  71.  
  72. else:
  73. print ("Invalid choice")
  74. #when you choice for example 15 program will preint invalid choice
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement