Python 3 Statistics compute deviationSolutionimport statisti
Python 3 Statistics: compute deviation
Solution
import statistics #import the statistics package
 A = [4,6,7,9,10,12] #A is the list of values
 print(statistics.stdev(A)) #stdev from statistics package is the default method caluclates standard deviation.
\'\'\' below is the process without using statistics library. however, below is not efficient due to floating point precisions.\'\'\'
 import math #import math
 mean=sum(A)/float(len(A)) #caluclate mean
 dev=math.sqrt(sum(pow(x-mean,2) for x in A)/float(len(A))) #caluclate deviation
 print(dev)
![Python 3 Statistics: compute deviationSolutionimport statistics #import the statistics package A = [4,6,7,9,10,12] #A is the list of values print(statistics.std Python 3 Statistics: compute deviationSolutionimport statistics #import the statistics package A = [4,6,7,9,10,12] #A is the list of values print(statistics.std](/WebImages/37/python-3-statistics-compute-deviationsolutionimport-statisti-1111454-1761589419-0.webp)
