Python Forum

Full Version: Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def median(numbers):
"""Find the median of the given list of numbers.

How to find the median:
https://www.mathsisfun.com/median.html

Note: Write your own implementation and do not use any libraries. You will need to sort the list.

params:
numbers (list) A list containing either int or float elements

return (numeric) The median value as either an int or float
"""
if len(numbers)%2==0:
pass
else:
return numbers[len(numbers)//2-1]
Sorry sent before I asked my question:

How to find the median of the given list of numbers.I started this part but I am a little bit confused on how to finish it.
The median is the value that is halfway between the smallest and largest values. If I gave you the numbers 3, 1, 4, 5, 2, how would you find the median?
(Nov-23-2020, 12:36 AM)Livi444 Wrote: [ -> ]How to find the median of the given list of numbers.I started this part but I am a little bit confused on how to finish it.
How - did you check the link in the assignment?
Post your code in python tags, full traceback if you get any error - in error tags.