David - 1 year ago 255
Python Question

# 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 divides to get that students average grade which displays in table format.

What I need to do, is loop through that whole process 9 more times. So essentially, Ill be asking 9 more students the same input, which then Ill need to display in the table format.

My question is how would I loop through the process that I have right now 'x' amount of times, then display the average of all students.

This is my code right now:

``````   # 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 in     range(assignments)]

# count average,

print()
print('NET ID \t Average Final Grade')
print('---------------------------------')

for number in range(1):

main()
``````

And this is how it looks on console:

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 in range(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 in     range(assignments)]

# count average,

print()
print('NET ID | Average Final Grade')
print('---------------------------------')

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