Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bouquets = {
- 'Романтика': {
- 'состав': ['розы', 'гипсофила'],
- 'цена': 2500,
- 'количество': 15
- },
- 'Нежность': {
- 'состав': ['лилии', 'эустома'],
- 'цена': 2200,
- 'количество': 10
- },
- 'Страсть': {
- 'состав': ['красные розы', 'берграс'],
- 'цена': 3100,
- 'количество': 8
- }
- }
- def view_description():
- for name, details in bouquets.items():
- print(f"{name}: состоит из {', '.join(details['состав'])}")
- def view_price():
- for name, details in bouquets.items():
- print(f"{name}: {details['цена']} руб.")
- def view_quantity():
- for name, details in bouquets.items():
- print(f"{name}: в наличии {details['количество']} шт.")
- def view_all():
- for name, details in bouquets.items():
- print(f"--- {name} ---\n"
- f" Состав: {', '.join(details['состав'])}\n"
- f" Цена: {details['цена']} руб.\n"
- f" В наличии: {details['количество']} шт.\n")
- def purchase():
- total_price = 0
- while True:
- bouquet_name = input("Введите название букета для покупки (или 'n' для выхода): ")
- if bouquet_name.lower() == 'n':
- break
- if bouquet_name not in bouquets:
- print("Такого букета нет в наличии.")
- continue
- try:
- quantity = int(input(f"Сколько букетов '{bouquet_name}' вы хотите купить? "))
- if quantity <= 0:
- print("Количество должно быть положительным.")
- continue
- if bouquets[bouquet_name]['количество'] >= quantity:
- bouquets[bouquet_name]['количество'] -= quantity
- current_purchase_price = bouquets[bouquet_name]['цена'] * quantity
- total_price += current_purchase_price
- print(f"Вы купили {quantity} шт. '{bouquet_name}'. "
- f"Сумма: {current_purchase_price} руб. "
- f"Осталось: {bouquets[bouquet_name]['количество']} шт.")
- else:
- print(f"Недостаточно букетов. В наличии только {bouquets[bouquet_name]['количество']} шт.")
- except ValueError:
- print("Пожалуйста, введите корректное число.")
- print(f"\nОбщая сумма вашей покупки: {total_price} руб.")
- def main():
- while True:
- print("\n--- Меню цветочного магазина ---")
- print("1. Просмотр описания букетов")
- print("2. Просмотр цен")
- print("3. Просмотр количества")
- print("4. Показать всю информацию")
- print("5. Совершить покупку")
- print("6. Выход")
- choice = input("Выберите пункт меню: ")
- if choice == '1':
- view_description()
- elif choice == '2':
- view_price()
- elif choice == '3':
- view_quantity()
- elif choice == '4':
- view_all()
- elif choice == '5':
- purchase()
- elif choice == '6':
- print("До свидания! Приходите еще!")
- break
- else:
- print("Неверный пункт меню. Попробуйте снова.")
- main()
Advertisement
Add Comment
Please, Sign In to add comment