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

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad