Python statistics.median_high() Function
The Python statistics.median_high() function calculates the high median of the given data set. Before calculating the high median this functions sorts the data in the ascending order.
Note: In this function if the data values are odd then it returns middle value, otherwise; it returns large value from the two middle numbers.
Syntax
Following is the basic syntax of the statistics.median_high() function −
statistics.median_high(data)
Parameters
Here, the data values can be used as any sequence, list or iterator.
Return Value
This function returns the middle value in the given data.
Example 1
In the below example we are calculating the high median of the given data using statistics.median_high() function.
import statistics x = statistics.median_high([1, 3, 5, 7, 9, 11]) print(x)
Output
The output obtained is as follows −
7
Example 2
Here, we are calculating the high median fro the negative float values using statistics.median_high() function.
import statistics x = statistics.median_high([0.1, -3.3, 5, -3.7, -9, 11]) print(x)
Output
The result is produced as follows −
0.1
Example 3
Now we are calculating high median for the even data set using statistics.median_high() function.
import statistics x = statistics.median_high([2, 4, 6, 8, 10]) print(x)
Output
This produces the following −
6
python_modules.htm