Python statistics.mean() Method
Python statistics.mean()Used to calculate the arithmetic mean (average) of a given dataset.
Syntax
The syntax of the statistics.mean() method is as follows:
statistics.mean(data)
Parameter description:
- data-- An iterable containing numeric values, such as a list or tuple.
Return Value
The function calculates and returns the arithmetic mean of the dataset 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)
data = [1, 2, 3, 4, 5]
mean = statistics.mean(data)
print(mean)
Output:
3.0
In the above example, the given dataset is [1, 2, 3, 4, 5], and the arithmetic mean calculated using the mean() function is 3.0.
The arithmetic mean is one of the commonly used statistics. It represents the sum of a set of data divided by the number of data points, and is used to measure the central tendency of a dataset.
Other Extensions
Python statistics Module