pythonV1V2/第20讲巅峰对决/课堂成果/课后作业_珠宝商人.py
sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

19 lines
657 B
Python
Raw Permalink 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.

'''珠宝商人
假设你是一家珠宝店的老板,用名为 jewelry 的字典存储了珠宝的相关信息。现在,你想要查看一款珠宝的价格,请编写一个程序输出该珠宝的价格。
编写一段代码,要求如下:
已知 jewelry={"项链":1000,"戒指":2000,"手链":1500}
(1) 输入要查价格的珠宝名称,并存储在 name 变量中
(2) 用 price 变量存储查询到的价格
(3) 输出:'珠宝名称'的价格是'××'
'''
jewelry = {"项链": 1000, "戒指": 2000, "手链": 1500}
name = input("请输入要查价格的珠宝名称:")
price = jewelry[name]
print(name + "的价格是" + str(price))