
- Mean– mean is usually the average of all the elements(number) divided by the count of elements.
- Median– the median is the middle number among all the numbers divided by the count or frequency of the number. Like in 2, 3, 4, 5, 5, 6, 7, and 8, 5/2 will be the median.
- Mode– the mode is the middle number among all the numbers. Like in 2, 3, 4, 5, 5, 6, 7, and 8, 5 will be the mode.
#!/usr/bin/env pythondef mean(arr, geometric= False):if arr == []:return Noneif geometric:prod = 1for i in arr:prod *= ireturn round(prod**(1/len(arr)), 2)else:return sum(arr)/len(arr)def median(arr):if arr == []:return Nonearr.sort()if len(arr)%2 != 0:return arr[len(arr)//2]else:return (arr[len(arr)//2 - 1] + arr[len(arr)//2])/2def mode(arr):if arr == []:return Nonecounts = {}for i in set(arr):count = arr.count(i)counts[count] = ireturn counts[max(counts.keys())]