Calculating the median from a list in Python. #python
def median(l): sortedl = sorted(l) mid = (len(sortedl) -1) // 2 if (len(sortedl)) % 2: return (sortedl[mid] + sortedl[mid+1]) / 2.0 else: return sortedl[mid]