<prompt> Given an array of numbers, write a program to find the median value.10, 20, 30, 40  <response>: To find the median value of an array of numbers, you need to do the following:1. Sort the array in ascending order2. Check if the array length is an odd number or an even number3. If the length is an odd number, the median is the element in the middle of the sorted array4. If the length is an even number, calculate the median by finding the average of two middle elements in the sorted arrayHeres the code in Python that finds the median value of the given array:pythondef find_medianarr: Sort the array arr sortedarr n lenarr Check if the length is odd or even if n 2 0: Get the average of two middle elements return arrn2 - 1 arrn2 2 else: Get the middle element return arrn2Using the above function, we can find the median value of the given input array:pythoninput_arr 10, 20, 30, 40median find_medianinput_arrprintfThe median value of the given array is: medianOutput: The median value of the given array is: 25.0. 