How to Calculate Mean of List in Python
Posted on: February 23, 2021 by Ariessa Norramli
In this article, you will learn how to calculate the mean of a list in Python.
Let’s say you have a list named ‘a’ with value [1, 2, 3, 4, 5].
a = [1, 2, 3, 4, 5]
In order to calculate the mean of a list, you can use the statistics.mean()
method.
# Import statistics module
import statistics
a = [1, 2, 3, 4, 5]
print(statistics.mean(a))
# => 3
Note: The statistics.mean()
method functions by returning the mean of a supplied list. In statistics, mean
refers to the average of a set of values.
Share on social media
//