Computing the Average


#1




For some reason every time I run the code it takes the sum of all of the grades in the original grades list(1045.5) and divides them by the amount of numbers in the auto generated test list. I know this is probably something simple but I don't see what I'm doing wrong. Added entire code in case it's an issue with original sum code.

I get similar error messages every time I run my code to the following:

Oops, try again. grades_average([8, 2, 6, 6, 4, 7, 3]) returned 149.35714285714286 instead of the expected: 5.142857142857143


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
    
def grades_average(y):
    a = 0
    a = grades_sum(grades) / float(len(y))
    return a
    
print grades_sum(grades)  
print grades_average(grades)


#2

from the instructions:

Has one argument, grades, a list

okay, you call the argument y instead of grades. That is fine. but then this instructions:

Calls grades_sum with grades

since you renamed grades to y, you should do the same here. call grades_sum with y. Or of course you can also decide to make the argument grades like the instructions tell you, that decision is yours)


#3

Thanks! Knew it'd be easy. Got a little too cute with it I guess and ended up confusing myself. I tend to like to rename variables when there's something easily confused in other parts of the code. Just helps me isolate better usually. Guess not this time.


#4