1def calculate_median(n):
2 N = len(n)
3 n.sort()
4
5 #find the median
6 if N % 2 == 0:
7 #if N is even
8 m1 = N / 2
9 m2 = (N / 2) + 1
10 #Convert to integer, match post
11 m1 = int(m1) - 1
12 m2 = int(m2) - 1
13 median = (n[m1] + n[m2]) / 2
14 else:
15 m = (N + 1) / 2
16 # Convert to integer, match position
17 m = int(m) - 1
18 median = n[m]
19
20 return median
21
22# Doing Math With Python