Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-002

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
    pass

4 test cases · run your code against them in the editor