Let’s see how to calculate standard deviation in Python.
To calculate standard deviation of a sample we need to import statistics module.
Luckily there is dedicated function in statistics module to calculate standard deviation.
import statistics as s x = [1, 5, 7, 5, 43, 43, 8, 43, 6] standard_deviation = s.stdev(x) print("Standard deviation equals: " + str(round(standard_deviation, 2)))