Program to read a list of n integers and find their median.
Class 11th CBSE
Assignement
Q-11. Program to read a list of n integers and find their median.
Solution :-
n = int(input(“Enter the number of integers you’d like to enter: “))
l = list()
for i in range(n):
x = int(input(“Enter the integer: “))
l.append(x)
print(l, “is your given list.”)
l.sort()
print(l, “is the sorted list.”)
c = len(l)
if c%2 != 0:
med = c//2
print(l[med], “is the median.”)
else:
a = l[c//2]
b = l[(c//2) – 1]
s = a + b
med = s/2
print(med, “is the median.”)
Output :-

TRY THIS CODE

Fun & Easy to follow

Works on all devices

Your own Pace

Super Affordable
Popular Videos

UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer

SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer