我正在用python编写一个程序,允许用户输入班级学生人数,然后为每个学生输入3个测试成绩。它还需要显示学生的考试平均成绩、班级平均成绩以及班级中的最高和最低平均成绩。现在,在打印每个学生的成绩和平均水平后,我无法让它不打印班级平均水平。我也真的无法使最大值和最小值起作用,因为它随着每个学生的变化而变化为该学生的平均值。
students=int(input('Please enter the number of students in the class: '))
for number in range(students):
class_average == 0
first_grade=int(input("Enter student's first grade: "))
second_grade=int(input("Enter student's second grade: "))
third_grade=int(input("Enter student's third grade: "))
StudentAverage=(first_grade + second_grade + third_grade)/3
print("The student's average is", round(StudentAverage,2))
class_average= class_average + StudentAverage
print("The class average is", round(class_average/students,2))
maximum_num = 0
if StudentAverage > maximum_num:
maximum= StudentAverage
print("The maxiumum average is", round(maximum,2))
minimum_num = 100
if StudentAverage < minimum_num:
minimum= StudentAverage
print("The minimum average is", round(minimum,2))