Program to find largest and second largest value from the list of elements.
Class 11th CBSE
Assignment
Q-9. Program to find largest and second largest value from the list of elements.
Solution :-
#program to find the second largest number of list
# declaring the list
l =[]
#Number of elements will be entered by the user
n = int(input(“Enter the number of elements in the list:”))
# for loop to take the input
for i in range(0,n):
# The input is taken from the user and added to the list as the item
l.append(int (input(“Enter the item:”)))
print(“printing the sum of the list items..”)
# sorting the list
l.sort()
#displaying the second last element of the list
print(“The First largest element of the list is:”, l[-1])
print(“The second largest element of the list is:”, l[-2])
Output :-
TRY THIS CODE
Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable
Popular Videos
Play Video
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer
Play Video
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.
Chris Matthews
Designer