Python Program to find the largest element of an array


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


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

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

import array as arr

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

largest = a[0]

for i in a:
    if largest < i:
        largest = i

print("Largest element is : ", largest)

Output:

Largest element is :  90