# 9/9 grades variance wrong, but code same as with others

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

total = 0

return average

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

return variance ** 0.5

returns Oops, try again. grades_variance([82, 89, 53, 28, 32, 20, 86, 82, 54, 15, 49, 21]) returned 75.36073615 instead of the correct value 721.2430555556
or similar error regarding wrong value in variance``````

#2

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

total = 0

return average

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

return x ** 0.5

#3

Isn't my code basically the same?

#4

Hi son9o,

``````def grades_variance(scores):
variance = 0
for score in scores:
variance += ((average - score) ** 2.0)
variance = variance / float(len(scores)) #AND HERE IS YOUR PROBLEM.
return variance``````

Because, the sentence is into the "for", only need erase this space.

#5

#6

There seems to be a "gotchya" in the code. "Scores" is not defined or populated with anything. Here is how I did it after i figured that out.

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

total = 0

return average

variance = 0
variance += (average - score)**2