In statistics, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following:

a. An array of integers
b. An integer that indicates the number of elements in the array

The function should determine the median of the array. This value should be returned as a double. (Assume the values in the array are already sorted.) You’ll create two arrays: one with three elements (e.g. 1, 3, 7) and one with four elements (e.g. 2, 4, 5, 9).

Respuesta :

The program is an illustration of methods

What are function?

Function are collections of named code blocks, that are executed when called or evoked.

The median function

The median function written in Python, where comments are used to explain each line is as follows:

#This defines the function

def medianValue(myList, n):

   #This determine the median element for odd list elements

   if n%2 == 1:

       medianElement = float(myList[int((n - 1)/2)])

   #This determine the median element for even list elements

   else:

       medianElement = (float(myList[int(n/2)]) + float(myList[int(n/2) - 1]))/2

   #This returns the median element

   return medianElement

Read more about functions at:

https://brainly.com/question/26180959