Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

MenuDrivenPythonprogramusingdictionaryaccepts nameofmovieandtotalno.of allhalls movie screened followedbynamesofallhalls

+3 votes
asked Apr 25, 2020 by Steve (150 points)

Sample Output

Movie ID : 2001

Movie: Thappad

Movie Screening in Navi Mumbai : 3 halls

1. Fame  Vashi

2. Cinemax  Vashi

3. Big Cinemas  Kharghar

Movie ID : 2002

Movie: Sab Kushal Mangal

Movie Screening in Navi Mumbai : 2 halls

1.  Cinemax  Vashi

2.  Big Cinemas  Kharghar

 Display all details

1 Answer

0 votes
answered May 16, 2023 by Hope (300 points)
# Import the necessary libraries.
import sys

# Create a dictionary to store the movie details.
movie_details = {}

# Define a function to print the menu.
def print_menu():
  print("Welcome to the Movie Screening Menu!")
  print("1. Add a movie.")
  print("2. View all movies.")
  print("3. Exit.")

# Define a function to add a movie to the dictionary.
def add_movie():
  # Get the movie name from the user.
  movie_name = input("Enter the movie name: ")

  # Get the number of halls from the user.
  number_of_halls = int(input("Enter the number of halls: "))

  # Add the movie details to the dictionary.
  movie_details[movie_name] = number_of_halls

# Define a function to view all the movies in the dictionary.
def view_all_movies():
  # Print the list of movies.
  for movie_name in movie_details:
    print(movie_name)

# Define a function to exit the program.
def exit_program():
  sys.exit()

# Keep looping until the user wants to exit.
while True:
  # Print the menu.
  print_menu()

  # Get the user's choice.
  user_choice = input("Enter your choice: ")

  # Validate the user's choice.
  if user_choice not in ["1", "2", "3"]:
    print("Invalid choice. Please try again.")
    continue

  # Perform the action corresponding to the user's choice.
  if user_choice == "1":
    add_movie()
  elif user_choice == "2":
    view_all_movies()
  else:
    exit_program()
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...