Trying to print out some numbers from a 2 dimensional list.
I have one function that needs to print out the average grade per student. The other function should print out the average of all the students together.
How can I acces these numbers and make them function the way I want to? I tried appending them to a list so that I can get the 4 averages and then go /4 but it's only appending the last average number.
studentgrades = [ [95, 92, 86],[66, 75, 54],[89, 72, 100],[34, 0, 0] ]
def average_per_student(studentgrades):
child = 0
lst_average = []
for cijfers in studentgrades:
average = int(sum(cijfers) /3)
child += 1
result = 'child %d: gemiddelde %d' % (child, average)
lst_average.append(result)
vg = []
print(average)
vg.append(average)
print(vg)
return lst_average
def average_of_all_students(studentgrades):
pass
resultaat1 = average_per_student(studentgrades)
# print(resultaat1)
resultaat2 = average_of_all_students(studentgrades)
# print(resultaat2)