# testing entry of multiple numbers into a list.
from collections import Counter
s = raw_input("Please enter your numbers: ")
numbers = map(int, s.split())
print 'this is what you entered'
print "how many entries? ", len(numbers)
mean = sum(numbers)/len(numbers)
print 'and the Mean is', mean
mode = Counter(numbers)
print 'and the Mode is', mode.most_common(1)
def median(numbers):
numbers.sort()
if len(numbers)%2 == 1:
return numbers[len(numbers)/2]
else:
return (numbers[len(numbers)/2]+numbers[len(numbers)/2 -1])/2.0
print 'and the Median is', median
Asked
Active
Viewed 39 times
-2

Luke Woodward
- 63,336
- 16
- 89
- 104
1 Answers
1
I assume the 'strange output' you mention is the last line of output when you run your code:
and the Median is <function median at 0x0256D9B0>
(You may get a slightly different number.)
The reason is fairly simple. You're not calling the median
function, you're just printing it.
I think you want to replace the last line of your program with
print 'and the Median is', median(numbers)
Windows error or your Python coding? Your Python coding, without a shadow of a doubt.

Luke Woodward
- 63,336
- 16
- 89
- 104