{"id":25466,"date":"2021-11-16T08:39:28","date_gmt":"2021-11-16T03:09:28","guid":{"rendered":"https:\/\/python-programs.com\/?p=25466"},"modified":"2021-11-16T08:39:28","modified_gmt":"2021-11-16T03:09:28","slug":"python-statistics-median_high-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-statistics-median_high-method-with-examples\/","title":{"rendered":"Python statistics.median_high() Method with Examples"},"content":{"rendered":"
statistics.median_high() Method in Python:<\/strong><\/p>\n The statistics.median_high() method computes the data set’s high median. Before calculating the high median, the data is also sorted in ascending order using this method.<\/p>\n Note:<\/strong> It should be noted that if the number of data values is odd, it will return the exact middle value. If there are an even number of data values, it returns the larger of the two middle values.<\/p>\n Syntax:<\/strong><\/p>\n Parameters<\/strong><\/p>\n data:<\/strong> This is Required. It is the data values that will be used (it can be any sequence, list, or iterator).<\/p>\n Note:<\/strong> It is to be noted that if the data is empty, it returns a StatisticsError.<\/p>\n Return Value:<\/strong><\/p>\n Returns a\u00a0float value representing the data’s high median (middle value).<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n statistics.median_high() Method with Examples in Python<\/span><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n statistics.median_high() Method in Python: The statistics.median_high() method computes the data set’s high median. Before calculating the high median, the data is also sorted in ascending order using this method. Note: It should be noted that if the number of data values is odd, it will return the exact middle value. If there are an even …<\/p>\nstatistics.median_high(data)<\/pre>\n
Given list = [10, 20, 40, 15, 30, 13, 17]<\/pre>\n
The high median of the given list items [10, 20, 40, 15, 30, 13, 17] = 17<\/pre>\n
Given list = [2, 1, 3, 5, 7, 8]<\/pre>\n
The high median of the given list items [2, 1, 3, 5, 7, 8] = 5<\/pre>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import statistics module using the import keyword.\r\nimport statistics\r\n# Give the list as static input and store it in a variable.\r\ngvn_lst = [10, 20, 40, 15, 30, 13, 17]\r\n# Pass the given list as an argument to the statistics.median_high() method that\r\n# computes the high median of the given list items.\r\n# Store it in another variable.\r\nrslt = statistics.median_high(gvn_lst)\r\n# Print the high median of the given list items.\r\nprint(\"The high median of the given list items\", gvn_lst, \"= \", rslt)\r\n<\/pre>\n
The high median of the given list items [10, 20, 40, 15, 30, 13, 17] = 17<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Import statistics module using the import keyword.\r\nimport statistics\r\n# Give the list as user input using list(),map(),input(),and split() functions.\r\n# Store it in a variable.\r\ngvn_lst = list(map(int, input(\r\n 'Enter some random List Elements separated by spaces = ').split()))\r\n\r\n# Pass the given list as an argument to the statistics.median_high() method that\r\n# computes the high median of the given list items.\r\n# Store it in another variable.\r\nrslt = statistics.median_high(gvn_lst)\r\n# Print the high median of the given list items.\r\nprint(\"The high median of the given list items\", gvn_lst, \"= \", rslt)\r\n<\/pre>\n
Enter some random List Elements separated by spaces = 2 1 3 5 7 8\r\nThe high median of the given list items [2, 1, 3, 5, 7, 8] = 5<\/pre>\n","protected":false},"excerpt":{"rendered":"