Programming Examples

Python program to find the 2nd largest number from the list of the numbers entered through keyboard.


WAP to find the 2nd largest number from the list of the numbers entered through keyboard.

Solution

a=[]
n=int(input("Enter the number of elements : "))
for i in range(1,n+1):
    b=int(input("Enter element : "))
    a.append(b)
a.sort()
print("Second largest element is : ",a[n-2])
▶ RUN

Output/ Explanation:

Enter the number of elements : 5

Enter element : 23

Enter element : 45

Enter element : 2

Enter element : 34

Enter element : 1

Second largest element is :  34

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad