statistics.mean

Full name
statistics.mean
Library
statistics
Syntax

statistics.mean(data)

Description

The statistics.mean function returns the arithmetic mean of the elements in data, that is, the sum of the elements divided by the number of them.

Parameters
  • data: Sequence or iterable from whose elements you want to calculate the arithmetic mean.
Result

The statistics.mean function returns an integer or a float.

Examples

We can obtain the arithmetic mean of the numbers contained in a list with the following code:

a = [5, 8, 1, 9, 2]
statistics.mean(a)
5

If the arithmetic mean is not an integer, the function returns a value of type float:

statistics.mean([1, 2])
1.5
Submitted by admin on Mon, 03/22/2021 - 17:43