【发布时间】:2016-01-02 19:13:09
【问题描述】:
我必须编写代码来计算每个学生的三个平均成绩,并根据得到的平均成绩显示一条消息。
程序需要能够处理任意数量的学生;但每个学生只有 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 个年级。
-
你有什么问题?
-
请使用edit 链接正确格式化您的代码,并在问题正文中提出实际问题。
-
条件“more == 'y' and more == 'Y'”永远不会为真,因为它需要“more”同时保持 2 个不同的值。
-
我必须编写一个代码,它将:计算每个学生的三个成绩的平均值,并根据得到的平均成绩显示一条消息。该程序需要能够处理任意数量的学生;但每个学生只有 3 个等级。我必须使用方法来计算每个学生的平均分数,并根据平均值阻止适当的消息。这是我到目前为止的代码,我是股票
标签: python python-3.x