median value statistics code example
Example 1: median
def median(arr):
if len(arr) == 1:
return arr[0]
else:
arr = sorted(arr)
a = arr[0:round(len(arr)/2)]
b = arr[len(a):len(arr)]
if len(arr)%2 == 0:
return (a[len(a)-1]+b[0])/2
else:
return a[len(a)-1]
Example 2: what is a median
Median of a triange is a line that goes from a vertex of the triangle
to the midpoint of the opposite side of that vertex.