python 利用条件运算符:学习成绩>=90分用A表示,60-89分之间的用B表示,60分以下的用C表示。...

一、参考解法:

score = int(input('输入分数:'))
print("A" if score>89 else('B' if score>59 else 'C'))

 

二、参考解法:

while 1:
    score = int(input('输入分数:'))
    mark = [90,60,0]
    result=['A','B','C']
    for i in range(0,3):
        if score>=mark[i]:
            print('%d属于:%s'%(score,result[i]))
            break

 

三、参考解法:

def grade(score):
    if score >=90:
        print("A")
    elif score>=60:
        print("B")
    else:
        print("C")
while 1:
    score = int(input('输入分数:'))
    grade(score)

 

转载于:https://www.cnblogs.com/python-xkj/p/9223862.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值