# Program to print the Largest Element in an Array in Python

Program to print the Largest Element in an Array in Python. This program contains array initialisation, if conditional statement and for loop. This program is for beginners, class 11,12 and B tech Computer science students.

### What is an Array ?

A Python Array is a collection of common type of data structures having elements with same data type. It is used to store collections of data.

### Working of program :

The initialised array a=[1,3,9,56,44,25,55] will be crawled down to the last element. The for loop will start from the beginning of array it will be first compared to the 0 value after that in next iteration the previously largest digit is compared to the newly iterated array element. After crawling down all the Elements the largest one is left and printed.

### Source code :

``````a=[1,3,9,56,44,25,55]
p=0
for i in range (0,len(a)):
if a[i]>p :
p=a[i]
print ("the greatest n.o is",p)``````

### Explanation of Source code :

Step 1 : Array is initialised.
a=[1,3,9,56,44,25,55]
Step 2: A variable is initialised.
p=0
Step 3: For loop is initialised.
for i in range (0,len(a)):
Step 4: conditional statement is used
if a[i]>p :
p=a[i]
Step 5: The greatest number is printed.
print (“the greatest n.o is”,p)

### Ouput:

```>>>
RESTART: C:\csstudy\source code file 2\Python program to print the largest element in an array.py
the greatest n.o is 56
>>> ```

### Output Explanation :

the greatest n.o is 56
The greatest number is printed that is 56.

### Conclusion :

The program is running fine.

Thank you for learning, reading and downloading the source code of Program to print the Largest Element in an Array in Python. This program contains array initialisation, if conditional statement and for loop. This program is for beginners, class 11,12 and B tech Computer science students. click the below link for programs , practical files for class 11,12 and project file in python language:
csstudy.in/category/python-programs/
Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
Computer Science Practical file for class 12 Term-2 – CS Study
Python Projects for Class 12 with Source Code (Mysql Connectivity) – CS Study