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.
- A list is initialized.
- Using for loop, input the numbers.
- Each iteration is appended in the list.
- A variable with name “big” is initialized with zero.
- For each entry, a loop begins.
- If the condition is imposed for the comparison of numbers:
- Big is updated if the condition is matched.
- The number which is biggest is displayed.
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)
Enter the no. : 5 Enter the no. : 9 Enter the no. : 2 The Biggest no. of all 3 is: 9