Calculate mean, median values of this list water = [1,2,3,4,2,4,2,4,5,2,3,4,2,1,3,4,3,2,5,1]
def mean(numbers): total_sum = 0; for n in numbers: total_sum += n count = len(numbers) avg = total_sum / count return avg def median(numbers): numbers.sort() #sort the list count = len(numbers) #get the length of the list isEven = count % 2 == 0 #check if this list is of even length if (isEven): #find the two numbers in the middle of the list mid = math.floor( count / 2 ) a = numbers[mid - 1] b = numbers[mid] #find the average of these two numbers ans = mean([a, b]) else: ans = numbers[math.floor( count / 2 )] return ans