求学生成绩在哪个区间,用哪一种方法比较好用,用了很多方法,就是统计不进去属于哪个区间。。
score = int(input("请输入一个在 0-100 之间的数字:"))
degree = "ABCDE" # 等级为ABCDE
num = 0
while score > 100 or score < 0:
score = int(input("输入错误!请重新输入一个在 0-100 之间的数字:"))
else:
num = score // 10
if num < 6: num = 5
print("分数是{},等级是{}".format(score, degree[9 - num]))
可以使用多重判断语句进行分级