Commit 8639290a by BellCodeEditor

auto save

parent b7498cbe
Showing with 46 additions and 1 deletions
dict = {"name":"小明","age":"12","name":"小齐"}
print(dict['name'])
fruit = {"苹果":"4.98","葡萄":"9.80","哈密瓜":"3.50"}
fruit.clear()
print(fruit)
info = {"name":"创造师","age":13,"course":"python"}
for i in info.values():
print(i)
\ No newline at end of file
student1 = {'语文': 91, '数学': 88, '英语': 85} student1 = {
'语文': 91,
'数学': 88,
'英语': 85
}
student2 = {'语文': 97, '数学': 98, '英语': 90} student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93} student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3} score = {'悟空': student1, '诺依': student2, '小贝': student3}
......
student1 = {'语文': 91, '数学': 88, '英语': 85}
student2 = {'语文': 97, '数学': 98, '英语': 90}
student3 = {'语文': 95, '数学': 100, '英语': 93}
score = {'悟空': student1, '诺依': student2, '小贝': student3}
while True:
# 第一步:要取出学生名字对应的成绩字典
print("录入学生姓名,按q键退出!")
name= input("录入查询的学生姓名:")
# 第二步:通过遍历来取出该同学的各科成绩
if name in score:
info = score[name]
print("*"* 30)
for k,v in info.items():
print(k,v)
print("*"*30)
# 第三步:当用户录入错误时,应该如何反馈信息给用户
elif name == "q":
break
else:
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