Python program to Get Prices of Products

products = {"Grape":5.9, "Guava": 4.5, "Mango":4.8, "Cashew":2.4, "Banana":3.0, "Pear": 5.8} for pro, price in products.items(): print(pro, " = ", price) cost = 0 while True: pro = input("Select product (n=nothing): ") if pro == 'n': break qty = int(input("Number of product? ")) cost += products[pro]*qty print("Price of product(s): ",cost)

 

 

Output:

Grape  =  5.9
Guava  =  4.5
Mango  =  4.8
Cashew  =  2.4
Banana  =  3.0
Pear  =  5.8
Select product (n=nothing): Banana
Number of product? 4
Select product (n=nothing): Guava
Number of product? 3
Select product (n=nothing): n
Price of product(s):  25.5

Process finished with exit code 0