3.5. Exercise: Finding Median ¶
Calculus exam results are announced and your result is above the announced average. You want to have an idea about the letter grade you will get, and to do this you ask everyone you know about their exam results. You want to calculate the median of the results, which will give you some more idea about the distribution of the grades so that you can take a better guess about your letter grade.
Write a function named find_median that takes a list of integers as the distribution of the grades and returns an integer as the median of this distribution. If the list has an even length, the function must return the higher of the two middle elements.
Hint: You can use the built-in function \(\color{purple}{\texttt{sorted()}}\) to get the grades in the increasing order.
Sample I/O:
>>> find_median([72,32,49,20,33])
33
>>> find_median([27,48,9,63,99,61,33,80,43,84,39,46,40,46,16,55,69,43,11,57])
46