5. Computing the average


#1



This average number turns out to be wrong. Can you help me to figure out what's wrong with it?

https://www.codecademy.com/courses/python-intermediate-en-7mgOa/1/2?curriculum_id=4f89dab3d788890003000096#

Oops, try again. grades_average([8, 2, 0, 9, 0, 5, 7, 2]) returned 80.42307692307692 instead of the expected: 4.125


grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for x in scores:
        total += x
    return total

print grades_sum(grades)

def grades_average(scores):
    sums = grades_sum(grades)
    x = sums / float(len(grades))
    return x
    
print grades_average(grades)


#2

Your function ignores the data that is given to it when it is called


#3

In what way exactly?


#5

There are a couple ways that your could change your code so that it will work:
A. Change the argument in your grades_average function from scores to grades.

B. Make sure that the argument that is passed in (in this case grades_average(scores)) is used in the rest of your function. sums = grades_sum(grades) and x = sums / float(len(grades)) cannot use the argument scores.


#6

Thank you.This helped me.