Find Largest Element in Array
In this program, you will learn the python program code to find largest element in array list.
Program Code to Find Largest Element in Array
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #python program to find largest element def largest(arr,n): big = arr[0] for i in range(1, n): if arr[i] > big: big = arr[i] return big arr = [] print("Enter 5 numbers ") for i in range(5): item = int(input('Input Number : ')) arr.append(item) n = len(arr) Ans = largest(arr,n) print ("Largest Number in given array is : ",Ans) |
Output
Enter 5 numbers
Input Number : 3
Input Number : 2
Input Number : 6
Input Number : 5
Input Number : 1
Largest Number in given array is : 6
Check out our other Python examples