How to Calculate Mean of List in Python

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…

The post How to Calculate Mean of List in Python appeared first on CodeSource.io.

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.

The post How to Calculate Mean of List in Python appeared first on CodeSource.io.


Print Share Comment Cite Upload Translate
APA
Ariessa Norramli | Sciencx (2024-03-29T01:47:42+00:00) » How to Calculate Mean of List in Python. Retrieved from https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/.
MLA
" » How to Calculate Mean of List in Python." Ariessa Norramli | Sciencx - Tuesday February 23, 2021, https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/
HARVARD
Ariessa Norramli | Sciencx Tuesday February 23, 2021 » How to Calculate Mean of List in Python., viewed 2024-03-29T01:47:42+00:00,<https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/>
VANCOUVER
Ariessa Norramli | Sciencx - » How to Calculate Mean of List in Python. [Internet]. [Accessed 2024-03-29T01:47:42+00:00]. Available from: https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/
CHICAGO
" » How to Calculate Mean of List in Python." Ariessa Norramli | Sciencx - Accessed 2024-03-29T01:47:42+00:00. https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/
IEEE
" » How to Calculate Mean of List in Python." Ariessa Norramli | Sciencx [Online]. Available: https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/. [Accessed: 2024-03-29T01:47:42+00:00]
rf:citation
» How to Calculate Mean of List in Python | Ariessa Norramli | Sciencx | https://www.scien.cx/2021/02/23/how-to-calculate-mean-of-list-in-python/ | 2024-03-29T01:47:42+00:00
https://github.com/addpipe/simple-recorderjs-demo