user
Task: Create a Python program to calculate the median of an array of numbers.

5, 15, 20, 2, 10

Answer:
assistant
def median_calc(nums): 
    nums.sort() 
    mid = len(nums)//2 
  
    if len(nums) % 2 == 0: 
        median = (nums[mid] + nums[mid - 1])/2 
    else: 
        median = nums[mid] 
  
    return median 
  
array = [5, 15, 20, 2, 10] 
n = len(array) 
  
med = median_calc(array) 
  
print("The median of given array is: " + str(med))