8. Part of Whole , Please can you help me to understand it


#1

Hi guys , i am new and just want to say i like codeacademy so much :slight_smile:

I started with academy yesterday and so far made all the way to LESSON : Student Becomes the Teacher.
I am not sure am i doing it too fast or that is ok ? (do i need to make longer breaks , or to read external topics....)

Anyway i cannot figure out how this works

def get_class_average(students):
results=[]
for student in students:
results.append(get_average(student))

return average(results)

"""Good! Now let's calculate the class average.
You need to get the average for each student and then calculate the average of those averages."""

Can please someone explain me step by step what is happening here , how does it works
what is what here , i am confused now how actualy we get average from student ? Do we get it from previous defined function def get_average(student): ? I hope someone will give me some advices and directions what to do. thank you upfront guys :sunny:


#2

so here you define your function:

def get_class_average(students):

which has one parameter (students), which contains a list of students (one, two or three) students.

Then we loop over the students, to get the individual students (which are dictionary's), then get_average calculate the average for the student, and appends it to the result list

then we have a list with weighted average for each student, of we which calculate the average to get the class average


#3

Thank you verry much for your efort :slight_smile: i appreciate it


#4

you understand or do you have more questions?


#5

Yeah thanks to you i undestand it now completly :blush: , no more questions atm cheers


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.