Skip to content Skip to sidebar Skip to footer

Get Average Grade For 10 Students - Python

I have a program that asks a user to enter a Student NETID and then what grades they got on 5 assignments plus the grade they got on the mid-term and final. It then adds them and d

Solution 1:

You really did the hardest part. I don't see why you couldn't so the loop of the average. Anyway:

student_count = 5;
A = [student_count]

for id_student inrange(student_count):    
    print("STUDENT #", id_student+1)

    # x holds the list of grades
    x = []

    # count of assignments 
    assignments = 5# Ask for a student ID from user
    NETID = int(input('Enter your 4 digit student NET ID: '))

    # fill list with grades from console input
    x = [int(input('Please enter the grade you got on assignment {}: '.format(i+1))) for i inrange(assignments)]

    midTermGrade = int(input('Please enter the grade you got on you Mid-Term: '))
    finalGrade = int(input('Please enter the grade you got on you Final: '))

    # count average, 
    average_assignment_grade = (sum(x) + midTermGrade + finalGrade) / 7print()
    print('NET ID | Average Final Grade')
    print('---------------------------------')

    for number inrange(1):
        print(NETID, " | ", format(average_assignment_grade, '.1f'),'%')

    A.append(average_assignment_grade);

grades_sum = sum(A)
grades_average = grades_sum / 5;
print("SUM OF ALL STUDENTS = " + grades_sum)
print("AVERAGE OF ALL STUDENTS = " + grades_average)

Update: As suggested above, you should make a function for a single student and loop through that function in another, since SO is not a coding service I won't do that for you, but I think you got the idea.

Post a Comment for "Get Average Grade For 10 Students - Python"