Variance varies verily


#1

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

Oops, try again. grades_variance([7, 6, 7, 8]) returned 0.265625 instead of the expected: 0.5

def grades_variance(scores):
    average = grades_average(scores)
    variance = 0
    for score in scores:
        variance += (average - score) ** 2
        variance = variance / len(scores)
    return variance
print grades_variance(grades)

#2

The line variance = variance / len(scores) should be on the same indentation level as the return statement.

In other words, this:

    for score in scores:
        variance += (average - score) ** 2
        variance = variance / len(scores)
    return variance

Should look like this:

    for score in scores:
        variance += (average - score) ** 2
    variance = variance / len(scores)
    return variance

#3

u should give different variable name for "variance = variance / len(scores)" and return that


#4

That's not the issue here.

The issue here is the indentation level of the line of code you just mentioned.


#5

aquaphoenix17 that was it i appreciate your help


#6

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