# Python - Statistics Module

The statistics module provides functions to mathematical statistics of numeric data. The following popular statistical functions are defined in this module.

## Mean

The `mean()` method calculates the arithmetic mean of the numbers in a list.

Example: Statistics Module
``````import statistics

print(statistics.mean([2,5,6,9]))  #output: 5.5
``````

## Median

The `median()` method returns the middle value of numeric data in a list.

Example: Statistics Module
``````import statistics

print(statistics.median([1,2,3,8,9]))  #output: 3
print(statistics.median([1,2,3,7,8,9]) )  #output: 5.0
``````

## Mode

The `mode()` method returns the most common data point in the list.

Example: Statistics Module
``````import statistics

print(statistics.mode([2,5,3,2,8,3,9,4,2,5,6]))  #output: 2
``````

## Standard Deviation

The `stdev()` method calculates the standard deviation on a given sample in the form of a list.

Example: Statistics Module
``````import statistics

print(statistics.stdev([1,1.5,2,2.5,3,3.5,4,4.5,5]))  #output: 1.3693063937629153
``````

Learn about the statistics module in Python docs.

Related Articles