@@ -0,0 +1,725 @@
+# -*- coding: utf-8 -*-%0A%22%22%22%0ACalculating the median%0A%0ACreated on Mon Feb 15 8:52:09 2016%0A%0A@author: liulixiang%0A%22%22%22%0A%0A%0Adef calculate_median(numbers):%0A    N = len(numbers)%0A    numbers.sort()%0A%0A    if N %25 2 == 0:%0A        m1 = N/2%0A        m2 = N/2 + 1%0A        # Convert to integer, match position%0A        m1 = int(m1) - 1%0A        m2 = int(m2) - 1%0A        median = (numbers%5Bm1%5D + numbers%5Bm2%5D)/2%0A    else:%0A        m = (N+1)/2%0A        m = m - 1%0A        median = numbers%5Bm%5D%0A    return median%0A%0Aif __name__ == '__main__':%0A    donations = %5B100, 60, 70, 900, 100, 200, 500, 500, 503, 600, 1000, 1200%5D%0A    median = calculate_median(donations)%0A    N = len(donations)%0A    print('Median donation over the last %7B0%7D days is %7B1%7D'.format(N, median))%0A

calculate median