Commit a6ec2bb1 by BellCodeEditor

auto save

parent 98f24605
Showing with 43 additions and 13 deletions
# 这是悟空为花果山小猴做臂力测试的程序代码 # # 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典
name=input('你叫啥名啊?') # dict_hero={"猴一":50,"猴二":46,"猴三":33,"猴五":24,"猴队长":66}
power=int(input('你臂力多少啊?')) # print(dict_hero)
list_hero=['猴三',10,'猴一',21,'猴五',22,'猴队长',29,'猴七',30] # #通过键修改值
for i in range(len(list_hero)): # dict_hero["猴队长"] = 100
if i%2==1 and list_hero[i]>=power: # dict_hero["猴三"] = 1
list_hero.insert(i-1,name)
list_hero.insert(i,power) # print(dict_hero)
break
print(list_hero) # #添加键值对
# 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典 # dict_hero['汤姆'] = 50
dict_hero=
print(dict_hero) # dict_hero['杰瑞'] = 20
# if "汤姆" in dict_hero:
# print("汤姆在字典中")
# else:
# print("汤姆不在字典中")
# print(dict_hero)
\ No newline at end of file
store_dict = {"乐事薯片":5,"奥利奥":8,"农夫山泉":2,"旺仔牛奶":5,"朱古力":7}
while True:
buy = input("请问你要买啥?")
if buy in store_dict:
print("好的,您选择的",buy,"需要支付",store_dict[buy],"元,扫码还是刷卡?")
else:
print("对不起,商品无货!")
a = input("请选择退出还是继续购买:1=退出,2=继续购买,3=添加商品")
if a == '1':
break
exit()
elif a == '2':
continue
elif a == '3':
new = input("请输入新商品名称:")
new_price = int(input("输入价格:"))
store_dict[new] = new_price
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment