Thread: Program error

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    24
    Rep Power
    0

    Program error


    I feel that my coding is right, but I always get the wrong median. May I have some assistance with this? Thanks!
    i figured it out!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    39N 104.28W
    Posts
    158
    Rep Power
    3
    Maybe you could elaborate?
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480

    median


    sort the data, then the median is

    data[len(data)//2]

    and if len(data) is even then so what, no one ever used a median anyway,

    and if they tell you it should be the average of the two center values and "they" is your boss then just do it,

    and always avoid philosophical arguments about the definition of median for an even sized data set.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo