Mean, median, and mode

Michael Fuhr mfuhr at fuhr.org
Mon Dec 6 20:00:43 CET 2004


Josiah Carlson <jcarlson at uci.edu> writes:


> "Robert Brewer" <fumanchu at amor.org> wrote:
> > 
> > Josiah Carlson wrote:
> > > 
> > > median = lambda x: x.sort() or x[len(x)//2]
> > 
> > That...is a really sneaky use of null return values. I like. :)
>
> Thank you, I'm just using a paradigm (exploiting lambdas) that I picked
> up while going through various functional programming modules.

print median([1, 2, 3, 4, 5, 6])
4

Shouldn't the median be 3.5?

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



More information about the Python-list mailing list