Program to print the biggest number out of three in Python

Written by

Himani Kohli

In this program, we will learn to find out the biggest number among the three in Python.

We’ll use for loop, if statement and append function to find out the biggest amongst all. It can also be executed for  n numbers just by changing the number of iterations in the for loop.

    Algorithm:

  1. A list is initialized.
  2. Using for loop, input the numbers.
  3. Each iteration is appended in the list.
  4. A variable with name “big” is initialized with zero.
  5. For each entry, a loop begins.
  6. If the condition is imposed for the comparison of numbers:
  7. Big is updated if the condition is matched.
  8. The number which is biggest is displayed.
  9. Exit 

Code:

l=[]

for i in range(3):

    n=int(input("Enter the no.:"))

    l.append(n)

big=0

for i in l:

    if i>big:

        big=i;

print("The Biggest no. of all 3 is:",big)

 

Output:

Enter the no. : 5

Enter the no. : 9

Enter the no. : 2

The Biggest no. of all 3 is: 9

 

Program to print the biggest number out of three in Python