python mean and standard deviation of list

Solutions on MaxInterview for python mean and standard deviation of list by the best coders in the world

showing results for - "python mean and standard deviation of list"
Noah
19 Jun 2018
1import numpy as np
2
3# list containing numbers only
4l = [1.8, 2, 1.2, 1.5, 1.6, 2.1, 2.8]
5
6# switch to numpy array
7v = np.array(l)
8
9mean = v.mean() # average ~ 1.86
10std = v.std() # stadrad deviation (square root of variance) ~ 0.48