Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Find Largest element in an array using Python

Today we will learn how to find largest element in an array using Python Language. In this section first to find large element we have to declare an array size and store the first element value in the max variable and than loop through the array from i to the size of array and compare elements with values of the max and we find the desired result.
For Example:
Enter the array size 5
9
2
23
41
87
Largest element in an array 87

Python Program to find largest element in an array

Steps needed for finding largest element in an array with help of Python

STEP 1: Initialize an array required in the code.

STEP 2: Store first element in variable max.

STEP 3: Iterate the loop through the array from i to length of the array and compare the value of max with elements of the array.

STEP 4: If we find any element is greater than max then max will hold the value of that element.

Python Program to find in an array
size=int(input("ENTER ARRAY SIZE "))
arr=[]
for i in range(size):
element=int(input())
arr.append(element)
print("LARGEST ELEMENTIS",max(arr))