import math xs = [0.5,0.7,0.3,0.2] # values (must be floats!) mean = sum(xs) / len(xs) # mean var = sum(pow(x-mean,2) for x in xs) / len(xs) # variance std = math.sqrt(var) # standard deviation