Data structures‎ > ‎Lists‎ > ‎

Median

get min, max, sum, mean, and median of a list containing numbers

import numpy  # for mean and median

# create a list
>>> x=[2,3,4,8]


>>> min(x)
2

>>> max(x)
8

>>> sum(x)
17

>>> numpy.mean(x)
4.25

>>> numpy.median(x)
3.5


>>> numpy.percentile(x, 25)
2.75

>>> numpy.percentile(x, 75)
5.0