Function Python27-Windows错误还是我的python编码?来自函数的奇怪消息

Function Python27-Windows错误还是我的python编码?来自函数的奇怪消息,function,mean,mode,median,Function,Mean,Mode,Median,我假设您提到的“奇怪输出”是运行代码时的最后一行输出: 中位数为 (您可能会得到一个稍有不同的数字。) 原因相当简单。您没有调用中值函数,只是在打印它 我想你想用 # 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 'thi

我假设您提到的“奇怪输出”是运行代码时的最后一行输出:

中位数为
(您可能会得到一个稍有不同的数字。)

原因相当简单。您没有调用
中值
函数,只是在打印它

我想你想用

# 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
Windows错误还是Python编码错误?你的Python代码,毫无疑问

print 'and the Median is', median(numbers)