Skip to content

Instantly share code, notes, and snippets.

@utinajerolps
Created September 11, 2014 21:53
Show Gist options
  • Save utinajerolps/5b2c4b6301f3de75b882 to your computer and use it in GitHub Desktop.
Save utinajerolps/5b2c4b6301f3de75b882 to your computer and use it in GitHub Desktop.
def median(yum):
sort_yum = sorted(yum)
len_yum = len(sort_yum)
med = 0
if len_yum % 2 == 0:
med = (sort_yum[len_yum/2] + sort_yum[len_yum/2 - 1]) / 2.0
elif len_yum == 1:
med = sort_yum[len_yum - 1]
else:
med = sort_yum[len_yum/2]
return med
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment