Python Program to find the smallest element of an array


In this program, you will learn how to find the smallest element of an array in Python.


a = arr.array('i', [40, 30, 10, 90, 55])

Example: How to find the smallest element of an array in Python

import array as arr

a = arr.array('i', [40, 30, 10, 90, 55])

smallest = a[0]

for i in a:
    if smallest > i:
        smallest = i

print("Smallest element is : ", smallest)

Output:

Smallest element is :  10