ID EN
Statistics

median

Python 3.11

Return the median (middle value) of numeric data, using the common “mean of middle two” method. If data is empty, StatisticsError is raised. data can be a sequence or iterable.

Syntax

PYTHON
statistics.median(data)

Examples

Example 1
PYTHON
>>> median([1, 3, 5])
3
Example 2
PYTHON
>>> median([1, 3, 5, 7])
4.0

See Also

StatisticsError median_low() median_high()