Dictionaries · 10 / 15 Exercise Easy

Coffee shop

Objective

Create a Python program that calculates the bill of a coffee shop using a dictionary of prices.

Instructions

  • Use this dictionary of prices: {"coffee": 1.50, "tea": 1.20, "juice": 2.00, "sandwich": 3.50}.
  • Read an integer n and then n products, one per line.
  • Add the price of each product that is in the dictionary.
  • If a product does not exist, immediately show Unknown product: X and do not add it.
  • At the end show Total: T, with the total to two decimals.
Input
3
coffee
sandwich
juice
Output
Total: 7.00

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise