输入一个学生的成绩,将其转化成简单描述:不及格(小于 60)、及格(60-79)、良 好(80-89)、优秀(90-100)。

方法1:使用完整的条件表达式

score = int(input("请输入分数:"))
grade = ''
if(score<60):
    grade = "不及格"
if(60<=score<80):
    grade = "及格"
if(80<=score<90):
    grade = "良好"
if(90<=score<100):
    grade = "优秀"
print("分数是{0},等级是{1}".format(score,grade))

方法2:利用多分支结构

score = int(input("请输入分数:"))
grade = ''
if score<60:
    grade="不及格"
elif score<80:
    grade="及格"
elif score<90:
    grade="良好"
elif score<=100:
    grade="优秀"

print("分数是{0},等级是{1}".format(score,grade))

拓展题:】输入一个分数。分数在 0-100 之间。90 以上是 A,80 以上是 B,70 以上是 C,60 以上是 D。60 以下是 E。

score = int(input("请输入一个在 0-100 之间的数字:"))
grade = ""
if score>100 or score&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值