statistics.fmean

Full name
statistics.fmean
Library
statistics
Syntax

statistics.fmean(data)

Description

The statistics.fmean function converts the elements of data into floats and returns their arithmetic mean, that is, the sum of the elements divided by the number of them.

According to the documentation, this function is faster than statistics.mean.

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

The statistics.fmean function returns a float.

Examples

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

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

Note that the result -despite having a null decimal part- is a float.

Submitted by admin on Tue, 03/23/2021 - 09:59