模拟成绩数据库

 1 name_score={}
 2 n=0
 3 while n==0:
 4     a="0"
 5     r=input("You are a teacher or a student?if you are a student,please input '1',else,you can input 't'")
 6     if r=="1":
 7         ask=input("please input your name,and we'll find your score.")
 8         if ask in name_score:
 9             print("He's score is:",name_score[ask])
10         else:
11             print("is not a student.")
12     else:
13         while a=='0':        
14             print("please input the student's name and he's score")
15             name=input("input he's name.")
16             score=input("input he's score.")
17             name_score[name]=score
18             on=input("Do you have another student?if you have,input'y',else,input'no'.")
19             if on=='y':
20                 a='0'
21             else:
22                 a=1
23                 print("OK")     

这是一个模拟管理成绩数据库,模拟教师添加成绩与学生查询成绩的行为。

这次主要利用了字典的键值对来帮助查询

转载于:https://www.cnblogs.com/Exesoft-Mike/p/8414086.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值