score = float(input('请输入成绩:'))
if score >= 90:
    print('成绩等级为:A')
elif score >= 80 and score <= 89:
    print('成绩等级为:B')
elif score >= 70 and score <= 79:
    print('成绩等级为:C')
elif score >= 60 and score <= 69:
    print('成绩等级为:D')
else:
    print('成绩等级为:E')

注:在 Python 中,input() 函数用于从用户输入读取一行文本,并将其作为字符串返回。因此,需要将输入的字符串转换为浮点数类型。

Python 代码:根据百分制成绩输出等级 (A-E)

原文地址: https://www.cveoy.top/t/topic/mJ9x 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录