在Python中,你可以重复码5次通过插入 线→在范围(0,5)计数: 符合此必须被缩进的代码。 编写程序,输入百分比 分数的等级,为每个分配等级:0-20,E ... 81-100,A 打印每个等级有多少,平均分数为 ,以及最高和最低分数。Python。请帮我添加和最大和最小值
A=0
B=0
C=0
D=0
E=0
for count in range(0,5):
score = int(input("Type your class students' score."))
if score >81:
print("A")
A=A+1
elif score>61:
print("B")
B=B+1
elif score>41:
print("C")
C=C+1
elif score>21:
print("D")
D=D+1
else:
print("E")
E=E+1
print "There are",A,"number of A"
print "There are",B,"number of B"
print "There are",C,"number of C"
print "There are",D,"number of D"
print "There are",E,"number of E"
totalscore = sum(score)
highestscore = max(score)
lowestscore = min(score)
print "Average score is",totalscore/5
print "The highest score is",highestscore
print "The lowest score is",lowestscore
我已经做到了,但它从totalscore = sum(分数)不起作用。 我不知道如何获得平均分数以及最高和最低分数。 请帮忙。
你发现'score'仅仅是最后输入的号码?在单个数字上进行这些计算是没有意义的。提示:您需要将每个新的“分数”添加到像“list”这样的东西。然后你可以在那个'list'上做这些计算。 – TigerhawkT3
抱歉,在哪里以及需要输入什么来制作列表。 – AAA
这肯定会在你的教科书或其他课程材料。 – TigerhawkT3