Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Best Way to Find Python Mean or Calculate Arithmetic Mean in Python

Python mean() function is from Standard statistics Library of Python Programming Language. The basic purpose of Python mean function is to calculate the simple arithmetic mean of given data. The given data will always be in the form of a sequence or iterator such as list, tuple, etc.

The arithmetic mean is commonly known as average, or we can say the average of a given set of numbers is called mean of given number.

According to Wikipedia, simply the mean or average when the context is clear, is the sum of a collection of numbers divided by the number of numbers in the collection.

For further detail of arithmetic mean, you can read this Wikipedia article.

Following is the statistical formula of the arithmetic mean.

Arithmetic Mean Formula

Mean = sum of all given values/number of given values
The mean is basically the central point of the data.

 

Syntax of Python mean() Function

The syntax of mean() function in Python is as follows:
statistics.mean(data)

 

For reference, you may check Python Mean function syntax here.

Parameters of Python mean() Function


data
– This parameter can be any sequence or iterator (lists, tuples)
Note: If data is empty, mean() function raise a StatisticsError

 

Return Value of mean() in Python

Return value of mean() is a floating point number after calculating the average or
arithmetic mean of given data in the iterator (lists, tuples, etc…)

 

Python mean() Function Examples


Output of mean() Function in Python

3
0.9

 

LearnAndLearn.com © 2018 - All rights reserved