作业--用户输入数字0-100,判断成绩,用函数

 

 

 1 #作业
 2 # 作业:
 3 # 用户输入数字0-100
 4 # 程序判断:
 5 # 数字>90,成绩为A
 6 # 数字>80,成绩为B
 7 # 数字>70,成绩为C
 8 # 数字<60,成绩为D
 9 # 尝试用函数完成?
10 
11 def score(name):
12     print("welcome to %s".center(50,"-")%(name.upper()))
13 
14     while True:
15         choice = input("please your input score or exit q : ")
16 
17         if choice == "q": exit()
18         if choice.isdigit():
19             choice = int(choice)
20             if choice > 100:
21                 print("请输入0-100以内的数字")
22                 continue
23             if choice == 100:
24                 print("%s score is Full Score\n" %(name))
25             elif choice >= 90:
26                 print("%s score is A\n"%name)
27             elif choice >= 80:
28                 print("%s score is B\n"%name)
29             elif choice >= 60:
30                 print("%s score is C\n"%name)
31             else:
32                 print("%s score is D\n"%name)
33 
34 
35         else:
36             print("请输入0-100以内的数字")
37             continue
38 
39 name = input("please your input name: ")
40 score(name)

 

转载于:https://www.cnblogs.com/gaoyuan111/p/6816052.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值