我必须编写代码来计算每个学生的三个年级的平均值,并根据得到的平均成绩显示一条消息。Python;计算每个学生的三个年级的平均值
该计划需要能够处理任何数量的学生;但每个学生只有3个等级。我必须使用一种方法来计算每个学生的平均分数,并根据平均值确定适当的信息。
这是我到目前为止的代码,我坚持:
def main():
more = 'y'
while more == 'y' and more == 'Y':
numScore = int(input('How many test score per student: '))
for numtest in range(numScore):
print ("The score for test")
score = int(input(': '))
total += score
total = 0
print ("Student number", students + 1)
print ('-----------------------------------------')
avg = getAvg(numScore)
if avg > 90:
print ("You're doing excellent work")
elif avg > 85 and avg <= 90:
print("You are doing pretty good work")
elif avg > 70 and avg <= 85:
print ("You better get busy")
else:
print ("You need to get some help")
def getAvg (numScore):
avg = total/numScore
print ("The average for student number", student + 1, \ "is:", avg)
more = input('Do you want to enter another student test score and get the average score of the student (Enter y for yes and n for no): ')
main()
计算的三个等级平均为每一批学生和显示器的取决于所得到的平均成绩的消息。该计划需要能够处理任何数量的学生;但每个学生只有3个等级。 – William
你的问题是什么? –
请使用[编辑]链接正确格式化您的代码,并在问题主体中提出实际问题。 – MattDMo