Commit a52d1a25 by BellCodeEditor

auto save

parent 5b18c6ca
Showing with 16 additions and 9 deletions
...@@ -3,11 +3,18 @@ student2 = {'语文': 97, '数学': 98, '英语': 90} ...@@ -3,11 +3,18 @@ student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93} student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3} score = {'悟空': student1, '诺依': student2, '小贝': student3}
# 查询并打印出输入的名字对应的所有科目的成绩 # 查询并打印出输入的名字对应的所有科目的成绩
name = input("名字:") while True:#重复执行
print('*' *20) print("查询输入名字,退出输入q")#打印(查询姓名,退出q)
if name in score: name = input("名字:")#输入名字
score=score[name] print('*' *20)#打印********
for k,v in score.items(): if name in score:#如果名字在字典当中
print(k,v) info=score[name]#信息和字典匹配
print('*' * 20) for k,v in info.items():
print(k,v)
\ No newline at end of file print('*' * 20)
elif name=="q":
break
else:
print("查询有误重新查询")
print('*'*20)
print("结束程序")
\ 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