def __init__(self): self.items = { "Knife Set": 50.0, "Cutting Board": 20.0, "Mixing Bowl": 15.0, "Measuring Cups": 10.0, "Blender": 80.0, "Frying Pan": 35.0, "Spices Set": 25.0 } self.cart = {} def display_items(self): print("\nAvailable Items:") for item, price in self.items.items(): print(f"{item}: ${price:.2f}") print() def add_to_cart(self, item_name, quantity): if item_name in self.items: if item_name in self.cart: self.cart[item_name] += quantity else: self.cart[item_name] = quantity print(f"{quantity} x {item_name} added to cart.") else: print(f"Sorry, {item_name} is not available in the shop.") def view_cart(self): if not self.cart: print("\nYour cart is empty.") else: print("\nYour Cart:") total = 0 for item, quantity in self.cart.items(): price = self.items[item] * quantity total += price print(f"{quantity} x {item} - ${price:.2f}") print(f"Total: ${total:.2f}") print() def checkout(self): if not self.cart: print("\nYour cart is empty. Nothing to checkout.") else: total = sum(self.items[item] * quantity for item, quantity in self.cart.items()) print("\nCheckout Successful!") print(f"Your total is ${total:.2f}. Thank you for shopping!") print() def main(): shop = CookingShop() while True: print("Welcome to the Cooking Shop!") print("1. View Items") print("2. Add to Cart") print("3. View Cart") print("4. Checkout") print("5. Exit") choice = input("Enter your choice: ") if choice == "1": shop.display_items() elif choice == "2": item = input("Enter the name of the item you want to add: ") try: quantity = int(input("Enter the quantity: ")) shop.add_to_cart(item, quantity) except ValueError: print("Please enter a valid quantity.") elif choice == "3": shop.view_cart() elif choice == "4": shop.checkout() break elif choice == "5": print("Thank you for visiting the Cooking Shop. Goodbye!") break else: print("Invalid choice. Please try again.")