
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Program to find the largest element in an array
In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given an array, we need to calculate the largest element of the array.
Here we use the bruteforce approach in which we compute the largest element by traversing the whole loop and get the element.
We can observe the implementation below.
Example
# largest function def largest(arr,n): #maximum element max = arr[0] # traverse the whole loop for i in range(1, n): if arr[i] > max: max = arr[i] return max # Driver Code arr = [23,1,32,67,2,34,12] n = len(arr) Ans = largest(arr,n) print ("Largest element given in array is",Ans)
Output
Largest in given array is 67
All the variables are declared in global form as shown above
Conclusion
In this article, we have learned how to get the largest element from the array.
- Related Articles
- Python Program to find largest element in an array
- Golang Program to Find the Largest Element in an Array
- Program to find largest element in an array in C++
- C# Program to find the largest element from an array
- C++ Program to Find Largest Element of an Array
- Program to find out the index in an array where the largest element is situated in Python
- C# Program to find the largest element from an array using Lambda Expressions
- Kth Largest Element in an Array in Python
- Python Program to find the largest element in a tuple
- C++ Program to find the second largest element from the array
- Java program to find the largest number in an array
- Kth Largest Element in an Array
- Python Program to Find the Largest Element in a Doubly Linked List
- Java program to find the 3rd largest number in an array
- Java program to find the 2nd largest number in an array

Advertisements