Advertisement
Guest User

Untitled

a guest
May 20th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. #--FUNCTION SET UP--#
  2.  
  3. def calculation(movie_time):
  4. """To calculate seconds to X:XX:XX format"""
  5. hours = movie_time // 3600
  6. minutes = movie_time // 60
  7. seconds = movie_time // 6
  8. print("{}:{}:{}".format(hours, minutes, seconds))
  9.  
  10. return hours, minutes, seconds
  11.  
  12. def add_movie(movies):
  13. """Function to add a movie to the dictonary"""
  14. # Gets users movie and time frame and adds to major list
  15. movie_title = input("Please add your movie title here: ").title()
  16. true = True
  17. if movie_title not in movies:
  18. while true:
  19. movie_time = int(input("Please enter the movies time in seconds: "))
  20. if movie_time > 0:
  21. calculation(movie_time)
  22. print("Your updated list of current movies playing and their run time is {}\n".format(movies))
  23. # Starts code from start
  24. main()
  25. true = False
  26. elif movie_time <= 0:
  27. print("Please type a valid movie run time!")
  28. else:
  29. print("Please input a valid integer!")
  30. else:
  31. print("The movie {} has already been added to the list!".format(movie_title))
  32. main()
  33.  
  34. def del_movie(movies):
  35. """Delete a chosen movie from a input"""
  36. # Delete chosen movie from the list
  37. del_movie = input("Please input a movie to delete: ")
  38. if del_movie in movies:
  39. del movies[del_movie]
  40. print("You have deleted the movie {}".format(del_movie))
  41. else:
  42. print("Oops")
  43.  
  44. def edit_movie(movies):
  45. """To edit the movies running time"""
  46. # Edit chosen movies run time
  47. edit_movie = input("Please input the movie you want to change the run time: ").title().strip()
  48. if edit_movie in movies:
  49. new_movie = input("Which movie would you like to replace this with? :")
  50. movies[edit_movie] = new_movie
  51. print("Your updated list is {}".format(movies))
  52. else:
  53. print("oops")
  54.  
  55. def view_movie(movies):
  56. """To view the movies running time"""
  57. # View chosen movies run time
  58. view_movie = input("Please input the movie you want to view the run time: ").title().strip()
  59. for view_movie in movies.items():
  60. print(value)
  61.  
  62. def print_movie(movies):
  63. """To print all the movies"""
  64. # Prints all movies in major list
  65. print(movies)
  66.  
  67.  
  68. def main_menu():
  69. """Prints out the main menu of descions for user"""
  70. # Prints users choices
  71. print("""Please enter:
  72. (A) to Add a movie
  73. (D) to Delete a movie
  74. (E) to Edit the length of a movie
  75. (L) to get the Length of a movie
  76. (P) to print out all the movies and their times
  77. (Q) to Quit
  78. """)
  79. main() # run main function
  80.  
  81. def main():
  82. """Main function for menu choices"""
  83. # Iterates through menus descions and runs function if typed correctly
  84. movies = {}
  85. true = True
  86. while true:
  87. menu = input("Please type which option you would like: ").upper().strip()
  88. if menu == "A":
  89. print("You have chosen to add a movie...\n --------------------------")
  90. true = False
  91. add_movie(movies)
  92.  
  93. elif menu == "D":
  94. print("You have chosen to delete a movie\n")
  95. true = False
  96. del_movie(movies)
  97.  
  98. elif menu == "E":
  99. print("You have chosen to edit the length of a movie\n")
  100. true = False
  101. edit_movie(movies)
  102.  
  103. elif menu == "L":
  104. print("You have chosen to view the length of a movie\n")
  105. true = False
  106. view_movie(movies)
  107.  
  108. elif menu == "P":
  109. print("You have chosen to print all the movies and length\n")
  110. true = False
  111. print_movie(movies)
  112.  
  113. elif menu == "Q":
  114. print("#--THIS PROGRAM HAS NOW BEEN STOPPED--#\n")
  115. true = False
  116. else:
  117. print("Please type one of the following:\n --------------------------")
  118. main_menu()
  119.  
  120. #--RUN PROGRAM--#
  121. main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement