Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python statistics.mean() Method

Python statistics.mean() Method

Python statistics Module Python statistics Module

Python statistics.mean() Used to compute the arithmetic mean (average) of a given data set.

Syntax

The syntax of the statistics.mean() method is as follows:

statistics.mean(data)

Parameter Description:

Return Value

The function computes and returns the arithmetic mean of the data set as the result.

Example

The following example demonstrates the mean() function:

Example

import

statistics

data

=

[

1

,

2

,

3

,

4

,

5

]

mean

=

statistics.

mean

(

data

)

print

(

mean

)

Output result:


3.0

In the above example, the given data set is [1, 2, 3, 4, 5], and the mean() function computes an arithmetic mean of 3.0.

The arithmetic mean is one of the commonly used statistics; it is the sum of a set of data divided by the number of data points, used to measure the central tendency of a data set.

Python statistics Module Python statistics Module