# Having trouble with review 9/9

#1

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
#grades = [1, 4, 2, 3, 5, 7, 3, 8, 4]

total = 0

return average

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

return variance ** 0.5

the error i get is this :

Oops, try again. grades_variance([47, 6, 49, 50, 92, 68, 35]) returned 10920.4837278106 instead of the correct value 608.2448979592

EDIT: everytime i execute this exercise i get a different answer. for example :

grades_variance([74, 53, 21, 51, 7, 37, 51, 16, 37]) returned 19368.2263313609 instead of the correct value 399.1358024691

BUT, it prints this

1045.5
80.4230769231
4342.92307692
65.9008579377
None

Thanks for the help in advance.

#2

Bugs exist in this part of your code...

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

Point1.

Point2.
Back to previous exercise when we had to build function to calculate variance..

It was written..

Divide the total variance by the number of scores
You need to add one line of code there..

point3.
also this exercise tells you to do these..

Print out the following:

all of the grades
variance
standard deviation

But you haven't used your print_grades() function ?

#3

dude you are a legend hahah.

#4

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