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 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz