sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

33 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''请帮炸鸡店老板做一个点餐系统店内的商品、价格已经存储在menu字典中输入商品名称和数量打印顾客的小票算出消费总额。
已知:
menu = {'香辣鸡腿堡':19.5,'劲爆鸡米花':12,'黄金鸡块':12.5,'香辣鸡翅':12.5,'香甜玉米杯':9,'醇香土豆泥':7.5,'薯条':9,'秘汁全鸡':29.9,'百事可乐':8.5}
提示如下:
(1) 输出商品菜单 menu
(2) 创建空字典 total 、创建变量 price初始化为0
(3) 输入购买的商品名称、数量
(4) 更新商品总额 price
(5) 将购买的商品及数量添加到字典 total
(6) 输出购物小票 total输出消费总额 price
'''
menu = {'香辣鸡腿堡':19.5,'劲爆鸡米花':12,'黄金鸡块':12.5,'香辣鸡翅':12.5,
'香甜玉米杯':9,'醇香土豆泥':7.5,'薯条':9,'秘汁全鸡':29.9,'百事可乐':8.5}
print(menu)
total = {}
price = 0
while True:
food = input('请输入商品名称:')
num = int(input('请输入商品数量:'))
price = price + menu[food] * num
total[food] = num
print(total)
print(price)