Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #--FUNCTION SET UP--#
- def calculation(movie_time):
- """To calculate seconds to X:XX:XX format"""
- hours = movie_time // 3600
- minutes = movie_time // 60
- seconds = movie_time // 6
- print("{}:{}:{}".format(hours, minutes, seconds))
- return hours, minutes, seconds
- def add_movie(movies):
- """Function to add a movie to the dictonary"""
- # Gets users movie and time frame and adds to major list
- movie_title = input("Please add your movie title here: ").title()
- true = True
- if movie_title not in movies:
- while true:
- movie_time = int(input("Please enter the movies time in seconds: "))
- if movie_time > 0:
- calculation(movie_time)
- print("Your updated list of current movies playing and their run time is {}\n".format(movies))
- # Starts code from start
- main()
- true = False
- elif movie_time <= 0:
- print("Please type a valid movie run time!")
- else:
- print("Please input a valid integer!")
- else:
- print("The movie {} has already been added to the list!".format(movie_title))
- main()
- def del_movie(movies):
- """Delete a chosen movie from a input"""
- # Delete chosen movie from the list
- del_movie = input("Please input a movie to delete: ")
- if del_movie in movies:
- del movies[del_movie]
- print("You have deleted the movie {}".format(del_movie))
- else:
- print("Oops")
- def edit_movie(movies):
- """To edit the movies running time"""
- # Edit chosen movies run time
- edit_movie = input("Please input the movie you want to change the run time: ").title().strip()
- if edit_movie in movies:
- new_movie = input("Which movie would you like to replace this with? :")
- movies[edit_movie] = new_movie
- print("Your updated list is {}".format(movies))
- else:
- print("oops")
- def view_movie(movies):
- """To view the movies running time"""
- # View chosen movies run time
- view_movie = input("Please input the movie you want to view the run time: ").title().strip()
- for view_movie in movies.items():
- print(value)
- def print_movie(movies):
- """To print all the movies"""
- # Prints all movies in major list
- print(movies)
- def main_menu():
- """Prints out the main menu of descions for user"""
- # Prints users choices
- print("""Please enter:
- (A) to Add a movie
- (D) to Delete a movie
- (E) to Edit the length of a movie
- (L) to get the Length of a movie
- (P) to print out all the movies and their times
- (Q) to Quit
- """)
- main() # run main function
- def main():
- """Main function for menu choices"""
- # Iterates through menus descions and runs function if typed correctly
- movies = {}
- true = True
- while true:
- menu = input("Please type which option you would like: ").upper().strip()
- if menu == "A":
- print("You have chosen to add a movie...\n --------------------------")
- true = False
- add_movie(movies)
- elif menu == "D":
- print("You have chosen to delete a movie\n")
- true = False
- del_movie(movies)
- elif menu == "E":
- print("You have chosen to edit the length of a movie\n")
- true = False
- edit_movie(movies)
- elif menu == "L":
- print("You have chosen to view the length of a movie\n")
- true = False
- view_movie(movies)
- elif menu == "P":
- print("You have chosen to print all the movies and length\n")
- true = False
- print_movie(movies)
- elif menu == "Q":
- print("#--THIS PROGRAM HAS NOW BEEN STOPPED--#\n")
- true = False
- else:
- print("Please type one of the following:\n --------------------------")
- main_menu()
- #--RUN PROGRAM--#
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement