In this program, we will get the median of all the elements from the list.
Steps to solve the program
- Take an input list with some values.
- Sort list items with the sorted() function.
- Get the length of the sorted list.
- If the length of the list is an even number then the median of the list will average two mid-values of the list.
- If the length of a list is odd then the mid-value of the list will be
the median value.
Output :
Related Articles
- Python program to print a combination of 2 elements from the list whose sum is 10.
- Python program to print squares of all even numbers in a list.
- Python program to split the list into two-part, the left side all odd values and the right side all even values.
- Python program to get common elements from two lists.
- Python program to reverse a list with for loop.
- Python program to reverse a list with a while loop.