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])
Output

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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad