diff --git a/diy b/diy index e69de29..448582e 100644 --- a/diy +++ b/diy @@ -0,0 +1,16 @@ +student1={"语文":91,"数学":88,"英语":85} +student2={"语文":97,"数学":98,"英语":90} +student3={"语文":95,"数学":100,"英语":93} +score={"悟空":student1,"诺依":student2,"小贝":student3} + +while True: + name=input("名字:") + if name in score: + a=score[name] + print("*"*30) + for k,v in a.items(): + print(k,v) + print("*"*30) + break + else: + print("输入错误") \ No newline at end of file diff --git a/diy.py b/diy.py index 448582e..71e95ef 100644 --- a/diy.py +++ b/diy.py @@ -1,16 +1,11 @@ -student1={"语文":91,"数学":88,"英语":85} -student2={"语文":97,"数学":98,"英语":90} -student3={"语文":95,"数学":100,"英语":93} -score={"悟空":student1,"诺依":student2,"小贝":student3} +s1={"d":3,"p":5,"c":4} +s2={"d":5,"p":6,"c":4} +s3={"d":1,"p":0,"c":4} +score={"1":s1,"2":s2,"3":s3} +a=input("请输入姓名:") while True: - name=input("名字:") - if name in score: - a=score[name] - print("*"*30) - for k,v in a.items(): - print(k,v) - print("*"*30) - break - else: - print("输入错误") \ No newline at end of file + a=input("名字:") + if a in score: + a=score[name] + print("*"*10) diff --git a/diy2.py b/diy2.py index f99ad3e..be65712 100644 --- a/diy2.py +++ b/diy2.py @@ -1,6 +1,18 @@ -score = {'语文':91,'数学':88,'英语':85} -for k in score.items(): - input(score) -# 请对字典进行遍历,将保存的分数以键值对的形式提取打印出来 - +student1={"语文":91,"数学":88,"英语":85} +student2={"语文":97,"数学":98,"英语":90} +student3={"语文":95,"数学":100,"英语":93} +score={"悟空":student1,"诺依":student2,"小贝":student3} +while True: + print("请输入姓名,退出请按n") + name=input("名字:") + if name in score: + a=score[name] + print("*"*30) + for k,v in a.items(): + print(k,v) + print("*"*30) + elif print==n: + break + else: + print("输入错误")