Commit 35609509 by BellCodeEditor

auto save

parent 789165dc
Showing with 24 additions and 0 deletions
#已有成绩字典score
score={"小明":80,"小红":90}
#请用户输入姓名name
name=input("请输入姓名:")
#请用户输入成绩s
s=input("请输入成绩:")
#如果name在score中:
if name in score:
#判断s是否比之前的值大,如果s大于字典中name对应的值:
if int(s)>score[name]:
#把score中name对应的值更新为s,注意s应为整数
score[name]=int(s)
#输出score
print(score)
#否则:
else:
#输出score
print(score)
#否则:
else:
#新建一个name键,存储对应成绩,注意s应为整数
score[name]=int(s)
#输出score
print(score)
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