Find Smallest element in an array using Python
Find smallest element in an array
In this section we will learn how to find smallest element in an array with the help of Python language which is the scripting language. If we want to find smallest element from the array enter by the user so we have to compare one element to other until we get the desired element and print it.
ENTER ARRAY SIZE OF ARRAY 3
SMALLEST ELEMENT IS 6
Working Required for finding smallest element in an array:-
We can find smallest element in an array by following these steps:-
1. Initialize the required array size.
2. Use range function for working of the loop.
3.Take the input of array.
4. Print the smallest element in an array.
size=int(input("ENTER ARRAY SIZE")) arr= for i in range(size): element=int(input()) arr.append(element) print("SMALLEST ELEMENT",min(arr))