Commit 661e413f by BellCodeEditor

auto save

parent b7498cbe
Showing with 19 additions and 17 deletions
student1 = {'语文': 91, '数学': 88, '英语': 85}
student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3}
# 1创建一个字典,字典内包含张三,李四,王五,赵六4人的
# 英语,数学,科学成绩
# 2,做一个分数查询系统,重复查询,
# 输入姓名,返回各科成绩,
# 如姓名有误,返回姓名错误
# 按q推出查询,需要有按q推出的提示。
# 查询并打印出输入的名字对应的所有科目的成绩
while True :
name = input("名字:")
if name in score :
a = score[name]
print('*'*30)
for k,v in a.items():
print(k,v)
a={
'张三':{'英语':91,'数学':94,'科学':823},
'李四':{'英语':92,'数学':94,'科学':839},
'王五':{'英语':90,'数学':93,'科学':82},
'赵六':{'英语':90,'数学':95,'科学':83}
}
while True:
name=input("输入需要查询的名字")
if name=='q':
break
if name in a:
for i,j in a[name].items():
print(i,j)
else:
print('输入错误')
\ No newline at end of file
print("输入的名字有误")
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