In this python basic program, we will get the median of given numbers.
Steps to solve the program
- Take a list as input.
- Sort the given list using sort().
- Use the formula (n+1)/2 to find the median of the given list, where n is the length of the list.
- Print the output.
list1 = [45, 60, 61, 66, 70, 77, 80]
list1.sort()
a = (len(list1))/2
print("Median: ",list1[int(a)])
Output :
Median: 66