Computer Science, asked by richadhaniya, 3 months ago

Super market billing with python-
1. Display the names of products available.
2. Give options and ask the user to enter his choice.
3. If the product is not available display a message regarding
unavailability of the product.
4. If the product is available display all details of that product including
price.
5. Ask the user if he wants to buy the product. If he chooses yes,
display a message “Thank you for ordering.... Your product will be
delivered soon.”

Answers

Answered by Equestriadash
19

prod_dict = dict()

n = int(input("Enter the number of products to be added: "))

for i in range(n):

   x = input("Enter the product name: ")

   y = float(input("Enter the price: "))

   prod_dict[x] = y

   print()

print()

print("Product Name\n", "Price")

print()

for i in prod_dict:

   print(i, prod_dict[i])

print()

print("Product Names: ")

name_list = list()

for i in prod_dict.keys():

   name_list.append(i)

for i in name_list:

   print(i)

print()

cp_name = input("Enter the name of the product whose details you'd like to view: ")

if cp_name in prod_dict:

   print(cp_name, ":", prod_dict[cp_name])

   cp = input("Would you like to purchase this item? [YES/NO]: ")

   if cp == "YES" or cp = "Yes" or cp == "yes":

       print("Thank you for ordering! Your product will be delivered soon.")

else:

   print("No such product.")

Similar questions