Commit 0a7d456a by BellCodeEditor

auto save

parent f6cbf097
Showing with 27 additions and 0 deletions
#创建字典存储成绩
student1 = {"语文":88,"数学":90,"英语":99}
student2 = {"语文":88,"数学":90,"英语":99}
student3 = {"语文":88,"数学":90,"英语":99}
student4 = {"语文":88,"数学":90,"英语":99}
#创建学生字典
score={"张三":student1,"李四":student2,"王五":student3,"马三":student4}
#开始循环输入查找
while True:
print("请输入要查询的名字,退出请输入q")
name = input("请输入要查询的名字:")
print("*"*30)
#判断所输入的名字是否在学生字典
if name in score:
#创建变量存储对应的成绩
info = score[name]
#循环遍历字典,打印成绩
for k,v in info.items():
print(k,v)
print("*"*30)
elif name==q:
break
else:
print("输入错误,请重新输入!")
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