def stats(lista): """ returns mean and variance of the list lista. assumes that lista is not empty """ mean = sum(lista)/len(lista) variance = 0 for element in lista: variance += (element-mean)**2 return mean, variance/len(lista) lista = [1,1,1,2,2,2,2,2,3,3] mu, sigma2 = stats(lista) def length(vector): """ calculates the length of the vector, assumed to be a three-tuple of floating point numbers or integers""" x, y, z = vector return (x*x+y*y+z*z)**0.5