Let’s see how to calculate variance of an entire population in Python using pvariance.
To calculate variance of an entire population we need to import statistics module.
A variance of population calculation
Luckily, there is dedicated function in statistics module to calculate variance of an entire population.
import statistics as s x = [1, 5, 7, 5, 43, 43, 8, 43, 6] pvariance = s.pvariance(x) print("Variance of entire population equals: " + str(round(pvariance, 2)))