Smallest Element in Array Python

Smallest element in array in python. In python programming language, print the smallest element in the array. The smallest number in the sequence will be shown by this program. It will print the small element by confirming the value of the smaller element by testing each element in the array

arr = [100,500,700,900,1100]; 
min = arr[0]; 
for i in range(0, len(arr)): 
if(arr[i] < min): 
min = arr[i]; 
print("The smallest number is" + str(min)); 

 

Output:

Smallest element present in given array: 100

Decision Making Statement in Python

Decision making statements allow you to specify the order in which specific statements in your program are executed. You can define a condition and instruct the compiler to perform a specific action if the condition is met. If the condition isn’t met, you can tell the compiler to run a different block of code.

Selection statements are also known as decision control statements or branching statements in Python. The selection statement enables a program to test several conditions and execute instructions based on which of the conditions is true. Using this program we can execute the smallest element in array in python.

Str() Function to Find Smallest Element in Array in Python

The str() function in Python is used to convert a value into a string. It accepts an object as input and converts it to a string. Because str is the name of a Python pre-defined function and a reserved keyword, it cannot be used anywhere else. Python includes a set of built-in methods for working with strings.

Array in Python Program

Arrays in Python are a type of data structure similar to lists. They contain a variety of objects that can be of various data types. Furthermore, Python arrays can be iterated and have a number of built-in functions for dealing with them. 

An array is a set of objects, pictures, or numbers arranged in rows and columns. Arrays, among other things, are useful representations of multiplication concepts in mathematics.