75. Python Program to find the Second Biggest number from the given n numbers.
How does this program work?
- This program is used to find the Second Biggest number from the given n numbers using Python.
- Each element is compared with the next element, If the element is less than the other in comparison then the elements can be swapped.
- After doing this for each element of the given array, then we get the Output.
Here is the code
a = ((10,25,96,35,45,78,2))
n = len(a)
frst = 0
sec = 0
for i in range(n):
if a[i] > frst:
sec = frst
frst = a[i]
elif (a[i] > sec and a[i] != frst):
sec = a[i]
if (sec == 0):
print("There is no second biggest")
else:
print("Given 'n' numbers:")
print(a)
print("second biggest number is: ",sec)