Why does get_average(students) call to average(numbers)?


#1

Link to excercise: Just Weight and See

https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/2?curriculum_id=4f89dab3d788890003000096

Hi all, I have done this exercise correctly but... I don't know why this works. Particularly, I want to know how this get_average(students) function calls to the original average(numbers) function when the get_average(students) function doesn't have the argument (numbers). I passed the excercise and even printed out print get_average(lloyd) to see the interpreted result and it works. But, why?

Intuitively, I put homework = average(numbers["homework"]) * 0.1 thinking it would properly call the first function but it doesn't. Can someone clear this misunderstanding up for me?
Thanks!

def average(numbers):
    total = sum(numbers)
    total = float(total)
    total /= len(numbers)
    return total
    
def get_average(students):
    
    homework = average(students["homework"]) * 0.1
    quizzes = average(students["quizzes"]) * 0.3
    tests = average(students["tests"]) * 0.6
    return homework + quizzes + tests
print get_average(lloyd)


#2

Hi that functon

def average(numbers):
    total = sum(numbers)
    total = float(total)
    total /= len(numbers)
    return total

make t average of any list of number ... and this function

def get_average(students):
    homework = average(students["homework"]) * 0.1
    quizzes = average(students["quizzes"]) * 0.3
    tests = average(students["tests"]) * 0.6
    return homework + quizzes + tests
print get_average(lloyd)

will make the average of your student then this line

homework = average(students["homework"]) * 0.1

why it isn't homework = average(numbers["homework"]) * 0.1 ?
we put students because it's the argument of the function get_average() ...like you say you called the functon with lloyd like that get_average(lloyd) in the function it will look like that

homework = average(lloyd["homework"]) * 0.1

where you put the argument students when you call the functiont will take that place
Hope that will help you understand it