Thursday, 8 August 2013

Python, How to find the median?

Python, How to find the median?

I am trying to create a function that can get any number of inputs and
find the median. I feel like I am going about this all wrong, I cannot get
this functional.
what do i need to do?
1.I made my list
2.I asked user for inputs
3.I sorted with numpy
4.I printed median
import numpy
numbers = [1,2,3]
1 = input("Please type your first number")
2 = input("please type your second number")
3 = input("please type your third number")
median = numpy.median(numbers)
print(median)
What I am trying to accomplish:
What numbers would you like to find the median for? 1,2,3,4,5,6,7
The median is: 4

No comments:

Post a Comment