# Python statistics functions with program examples

### Python statistics functions:

Python has a good number statistics functions to save coding space and time. you can  call those functions with statistics library. You can get functions for mean, median,mode, standard deviation and variance. Here you can get examples with programs.

` ` ``` import statistics a= [1,2,3,4,5,5,6,7] #mean() Arithmetic mean (“average”) of data. print('Mean of list : ',statistics.mean(a)) #harmonic_mean() Harmonic mean of data. print('Harmonic of list : ',statistics.harmonic_mean(a)) #median() Median (middle value) of data. print('Median of list : ',statistics.median(a)) #median_low() Low median of data. print('Low median of list : ',statistics.median_low(a)) #median_high() High median of data. print('High median of list : ',statistics.median_high(a)) #median_grouped() Median, or 50th percentile, of grouped data. print('Median grouped of list : ',statistics.median_grouped(a)) #mode() Mode (most common value) of discrete data. print('mode of list : ',statistics.mode(a)) #pstdev() Population standard deviation of data. print('population standard of list : ',statistics.pstdev(a)) #stdev() Sample standard deviation of data. print('Sample standard deviation of list: ',statistics.stdev(a)) #pvariance() Population variance of data. print('Population variance of list: ',statistics.pvariance(a)) #variance() Sample variance of data. print('Sample variance of list: ',statistics.variance(a)) ``` ` ` ` `

Output:

Mean of list : 4.125
Harmonic of list : 2.864450127877238
Median of list : 4.5
Low median of list : 4
High median of list : 5
Median grouped of list : 4.5
mode of list : 5
population standard of list : 1.899835519196333
Sample standard deviation of list: 2.03100960115899
Population variance of list: 3.609375
Sample variance of list: 4.125

Reference: 