Question
Python: Creating dictionaries and functions -Create a dictionary named tickets_sold_dict. -Write a loop which prompts the user to input the following keysand values and store
Python: Creating dictionaries and functions
-Create a dictionary named tickets_sold_dict.
-Write a loop which prompts the user to input the following keysand values and store them in tickets_sold_dict. Continueto read in the items while exit is not entered. Be sureto convert the number of tickets sold to an integer.
Smart Figures 1096
Guardians of the Universe 2400
Rogue Eight 958
exit
-Use the keys function to access the keys intickets_sold_dict. Use a loop to print out the keys.
-Use the values function to access the values intickets_sold_dict. Use a loop to print out thevalues.
-Compute the sum of all of the values for the ticketssold. Print out the sum.
-Create a dictionary named movie_tickets_dict and assign thesevalues for the number of tickets sold.
Early Bird 511
Matinee 343
Evening 942
-Write a loop which allows the user to enter a key to search forin the movie_tickets_dict, if the key is in the dictionary, printout the number of tickets sold. If not print the thesearch key and " was not found".
-Write a function named total_sales_function thattakes four parameters: a dictionary, the price of anearly bird ticket, the price of a matinee ticket, andthe price of an evening ticket. Create adictionary tickets_dict. Use a loop tomultiply the price of each type of ticket by the numberof tickets sold. Store the key and the resultof the calculation in thetickets_dict. Return the tickets_dict.
-Call the function from within main with the followingarguments: movie_tickets_sold_dict, 4.00, 5.50, and6.25. Assign the returned dictionary totickets_cost_dict. Print out the keys and values withtwo decimal places of precision for each item of the returneddictionary tickets_cost_dict.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started