Use the keys function to access the keys in ticketssolddict


USE PYTHON 3 ONLY

1. Create a dictionary named tickets_sold_dict.

2. Write a loop which prompts the user to input the following keys and values and store them in tickets_sold_dict.  Continue to read in the items while exit is not entered.  Be sure to convert the number of tickets sold to an integer.

Smart Figures    1096

Guardians of the Universe 2400

Rogue Eight 958

exit

3. Use the keys function to access the keys in tickets_sold_dict.  Use a loop to print out the keys.

4. Use the values function to access the values in tickets_sold_dict.  Use a loop to print out the values.

5. Compute the sum of all of the values for the tickets sold.  Print out the sum.

6. Create a dictionary named movie_tickets_dict and assign these values for the number of tickets sold.

Early Bird 511

Matinee 343

Evening 942

7. Write a loop which allows the user to enter a key to search for in the movie_tickets_dict, if the key is in the dictionary, print out the number of tickets sold.  If not print the the search key and " was not found".

8.  Write a function named total_sales_function that takes  four parameters: a dictionary, the price of an early bird  ticket, the price of a matinee ticket, and the price of an  evening ticket.  Create a dictionary tickets_dict.  Use a  loop to multiply the price of each type of ticket by the  number of tickets sold.  Store the key and the result of  the calculation in the tickets_dict.  Return the tickets_dict.

9. Call the function from within main with the following arguments: movie_tickets_sold_dict, 4.00, 5.50, and 6.25.  Assign the returned dictionary to tickets_cost_dict.  Print out the keys and values with two decimal places of precision for each item of the returned dictionary tickets_cost_dict.

10. Create a dictionary named sense_hat_dict.  Store the following keys and access the values from the Sense Hat.

  • temperature
  • pressure
  • humidity
  • position: pitch,roll, and yaw dictionary object
  • acceleration: x, y, and z dictionary object

11. Print out the keys and values for each item.  Use the is-instance to determine if the value is a float (flt) or a dictionary (dict).

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Use the keys function to access the keys in ticketssolddict
Reference No:- TGS02275963

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)