Write a python function to calculate the median of user provided list of numbers


Topic: Write a python function to calculate the median of user provided list of numbers

Solution

def median(list):
  list.sort()
  list_length = len(list)
  if list_length % 2 == 0:
    return (list[int(list_length / 2) - 1] + list[int(list_length / 2)]) / 2
  return float(list[int(list_length / 2)])



List all Python Programs