You are viewing a single comment's thread. Return to all comments →
def median(array): n = len(array) if n % 2 != 0: return array[int(n/2)] else: return (array[int(n/2)-1]+array[int(n/2)])/2 def quartiles(arr): arr.sort() Q1 = median(arr[:len(arr)//2]) Q2 = median(arr) if len(arr) %2 != 0: Q3 = median(arr[(len(arr)//2)+1:]) else: Q3 = median(arr[(len(arr)//2):]) return int(Q1), int(Q2), int(Q3)
Seems like cookies are disabled on this browser, please enable them to open this website
Day 0: Mean, Median, and Mode
You are viewing a single comment's thread. Return to all comments →