Find Second Smallest Element in an Array using Python
Second Smallest Element
In this paragraph today we learn how to find second smallest element in an array with help of Python Programing concept.In Python it does not have arrays, but it has list with the help of using lists it is more easy and comfortable to work with in comparison to arrays.
Input : list = [11, 15, 2, 4, 91, 10, 20, 16, 14]
Second Smallest element is: 4
Working Required for finding second smallest element entered by the user
Step 1: Initialize the array list of element
Step 2: Input the elements from the user
Step 3: Compare it with all other elements entered by the user in the list.
Step 4: When we find desired output
Step 5: Print second smallest number.
Python Code for finding Second Smallest Element in an Array
n=int(input("ENTER ARRAY SIZE "))
for i in range(n):
print("SECOND SMALLEST ELEMENT IS ",arr)