Exam Statistics: 7. The Variance


#1



Exam Statistics: 7. The Variance


grades_variance([5, 9, 6, 4, 1, 4, 4, 1]) returned 1.3240142502 instead of the expected: 5.9375


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


#2

Indentation of this line matters.

variance += (average - score) ** 2
As you have to do this operation for all score (numbers)
But you introduce that line just after it and it keep changing final value of variance.


#3

Thank youuuuuuuuuuuu :slight_smile:


#4

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