Let’s see how to calculate geometric mean in Python.

To calculate geometric average we need to import statistics module.

Luckily there is dedicated function in statistics module to calculate geometric mean.

import statistics as s x = [1, 5, 7, 8, 43, 6] geometric_mean = s.geometric_mean(x) print("Geometric mean equals: " + str(round(geometric_mean, 2)))