The median
Task
Write a function median(cisla) that returns the median of a non-empty list of numbers: the middle value after sorting. For an even count the median is the average of the two middle values (the result of the / operator).
median([5, 1, 3])returns3,median([4, 1, 3, 2])returns2.5.
The original list must not change.
Examples
Call
print(median([5, 1, 3]))
Expected output
3
Call
print(median([4, 1, 3, 2]))
Expected output
2.5
After you submit, 5 hidden tests will also check your solution: one number, two equal numbers, a negative number, decimal numbers, the list stays the same.
You need to know
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.