Median


#1



Replace this line with your code.


#2

def median(numbers) :

x=sorted(numbers)
if len(x)%2==0 and len(x)!=1 :

    k=x[len(x)/2]     
    j= x[(len(x)/2) -1]



    return (j+k)/2.0


if len(x)%2!=0 and len(x)!=1 :
    total=0
    total=x[(len(x)/2) -0.5]
    return total
if len(x)==1 :
    return x[0]


return sorted_numbers[-1]

#3

FOr some reason this says list indices must be integers not float even though i am never passing in a float as an index


#4

This is a float, even if it equates to whole number... 3.0


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.