# Python Program to Find Largest and Smallest Number in an Array using For loop

ADVERTISEMENTS

__Python__ program to find largest and smallest number in an array using for loop. In this article, you will learn how to make python program to find largest and smallest number in an array using for loop.

### Source Code

```
# Python Program to Find Largest and Smallest Number in an Array using For loop
x, s, i, b, sm = [], 0, 0, 0, 0
# x - To store the array list of input numbers
# s - To store the size of the array
# b - To store the big element variable
# sm - To store the small element variable
print ("\n-----Enter the size of the array-----")
s = int (input ())
print ("\n-----Enter the ", s, " elements of the array-----\n")
for i in range (s):
x.append(int (input ()))
# It stored the first element of the array to check the element
b = x[0]
for i in range (1, s):
# It checks one by one with each value of an array
# To compare the value is smallest or largest
if b < x[i]:
b = x[i]
print ("\n-----The largest element is: ", b, "\n")
# It stored the first element of the array to check the element
sm = x[0]
for i in range (1, s):
# It checks one by one with each value of an array
# To compare the value is smallest or largest
if sm > x[i]:
sm = x[i]
print ("\n-----The smallest element is: ", sm, "\n")
```

### Output

`-----Enter the size of the array-----`

6

`-----Enter the 6 elements of the array-----`

`73`

42

423

42

342

14

`-----The largest element is: 423`

`-----The smallest element is: 14`