Find Median from list?


def median(n):
num = len(n)
if num % 2 == 0:
return (n[num/2 - 1] + n[num/2])/2.0
return n[int(num -1)]/2
I did use above code to find medain from the list as per instructed bt codeacademy. But I didn’t understand the uses of num % 2 == 0, what is it’s use in here ?


Try executing it for different values for num and see what you end up doing

and/or refer to how you manually compute median, because you need to do the same thing then