利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示 ...

论坛 期权论坛 脚本     
匿名网站用户   2020-12-20 18:41   74   0

程序分析:(a>b)?a:b这是条件运算符的基本例子

    def scoreOfStudent(self, score):
        score = float(score)
        if score >= 90:
            print("成绩为:%s" % ("A"))
        elif score >= 60:  # 在这种情况下,二者等效score >= 60 and score < 89
            print("成绩为:%s" % ("B"))
        else:
            print("成绩为:%s" % ("C"))

input the number:
60.1
成绩为:B
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP