All problems
Variance
Problem
Compute the population variance of a list of numbers:
var = sum((x - mean)^2) / N
Hint
Don't forget to subtract the mean before squaring.
Test cases
case 1
in: [[1,2,3,4,5]]
expected: 2
case 2
in: [[10,10,10]]
expected: 0
case 3
in: [[1,3]]
expected: 1
case 4
in: [[0,5]]
expected: 6.25
Starter codePython
def variance(data):
# Your code here
pass4 test cases · run your code against them in the editor