|
发表于 2020-5-27 17:20:35
|
显示全部楼层
这个地方有问题,因为比规定的学生数量要多1次,不知道为什么,明明规定了大于0......
因为你 while student > 0 的循环外面还输入了一次学生成绩所以多一个,正确代码:
- print("__________欢迎使用鱼饼成绩转换器!__________\n__________请按以下提示输入需要的成绩分类。__________")
- a = int(input("A类成绩需大于等于:"))
- b = int(input("B类成绩需小于:"))
- c = int(input("B类成绩需大于等于:"))
- d = int(input("C类成绩需小于:"))
- e = int(input("C类成绩需大于等于:"))
- print(e, "分以下的分数将被定义为D")
- student = int(input("请输入学生数量:"))
- i = student
- while student <= 0:
- print("请输入0以上的阿拉伯数字。")
- student = int(input("请重新输入学生数量:"))
- print("现在请依次输入分数(一次只可输入一个):")
- while student > 0:
- # 这个地方有问题,因为比规定的学生数量要多1次,不知道为什么,明明规定了大于0.....
- score = int(input())
- student -= 1
- if score >= a:
- print("A")
- elif c <= score < b:
- print("B")
- elif e <= score < d:
- print("C")
- else:
- print("D")
- print('请输入学生分数:',end='')
- print(i, "名学生分数已转换完。感谢您的使用。")
复制代码
|
|