119,427 views
16 votes
Create a dictionary called menu that gives the price of ice cream as $4.95, cookies as $2 and candy as $1. (Leave the dollar signs off.) Then, check the price of cookies.

User Roxxypoxxy
by
3.5k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

The following is written in Python and does exactly as described. It creates a dictionary called menu and adds both the keys and their corresponding price values. Then it creates a variable named cookie_price and gives it the value that is returned from using the key "cookies" in the menu dictionary. Finally, it prints out cookie_price

menu = {"ice cream": 4.95, "cookies": 2, "candy": 1}

cookie_price = menu.get("cookies")

print(cookie_price)

User Jason Prawn
by
3.1k points