Commit 2a513d90 by BellCodeEditor

auto save

parent f1980af8
Showing with 16 additions and 2 deletions
# 神奇百货中的物品已经帮你创建好啦,接下来要看你的了~
dict= {'可口可乐':3,'旺仔牛奶':4,'农夫山泉':1,'辣条':3,'巴西烤肉':2,'果冻':4,'乐事':5,'奥利奥':10,'巧克力':6}
\ No newline at end of file
dict= {'可口可乐':3.5,'旺仔牛奶':4,'农夫山泉':1,'辣条':3.9,'巴西烤肉':2,'果冻':3.5,'乐事':5,'奥利奥':10,'巧克力':6}
#1.输入商品名以及价格
#2.如果输入的商品在字典中则判断新输入的价格是否低于之前的价格,如果低于之前的价格则输出商品了,现价....元
#3.如果不低于,则输出商品涨价了,我们不买了
#4.如果该商品不在就将该商品添加到字典中,并输出商品已添加,价格为...元
k = input("商品名")
v = input("价格")
if k in dict:
if float(v)< dict[k]:
print(k+'降价了,现价'+v+'元')
else:
print(k+'涨价了,我们不买了')
else:
dict[k] = float(v)
print(k+'已添加,价格为'+v+'元')
\ 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