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.

The mean is basically the central point of the data.

## Syntax of Python `mean()`

Function

`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

`mean()`

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

## Python `mean()`

Function Examples

1 2 3 4 5 6 | # import statistics library import statistics print(statistics.mean([1,2,3,4,5])) print(statistics.mean([-1.0,2.7,-3.9,5.8])) |

Output of

`mean()`

Function in Python

3

0.9