关于使用Python——写成绩计算

条件:

    # 成绩计算*************************************************************************************
    # 输入一个成绩,然后进行判断。
    # 要求显示的结果:
    # 如果成绩在[0
    # 60]之间
    # 不及格
    # 如果成绩在[60
    # 70)之间
    # 等级是D
    # 如果成绩在[70
    # 80)之间
    # C
    # 如果成绩在[80
    # 90)之间
    # B
    # 如果成绩在[90 100]之间
    # A
    #
    # 可以使用if... else ...
    # 组合(不使用elif)
    # 也可以使用if... elif ...
    # 组合 

********************************************************************************************************************

    while True:
        score = input('你的成绩是:')
        score = int(score)
        if score >=0 and score< 60:
            print('成绩不及格,补考')
        elif score >= 60 and score < 70:
            print('成绩为D')
        elif score >=70 and score < 80:
            print('成绩为C')
        elif score >= 80 and score <90:
            print('成绩为B')
        elif score >= 90 and score <= 100:
            print('成绩为A')

运行结果:

你的成绩是:99
成绩为A
你的成绩是:55
成绩不及格,补考
你的成绩是:44
成绩不及格,补考
你的成绩是:69
成绩为D
你的成绩是:78
成绩为C
你的成绩是:88
成绩为B

猜你喜欢

转载自blog.csdn.net/qq_42543261/article/details/80998427
今日推荐