Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/dumbpy/median.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
A module that calculates the median of a list of numbers.
"""


def median(input):
"""
Calculate the median of the inputted list and return the result.

Parameters
----------
input : list
A non-empty list of numbers.

Returns
-------
float
The median value of the list. If the list length is even, the median is
the average of the two middle values.

Raises
------
TypeError
If x is not a list or contains non-numeric values.
ValueError
If x is an empty list.

Examples
--------
>>> median([3, 1, 2])
2
>>> median([1, 2, 3, 4])
2.5
"""
pass
Loading