Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code
#1
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]
Reply
#2
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.
Reply
#3
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?
Reply
#4
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020