0
17kviews
Write a Python Program to Find the Largest Among Three Numbers
1 Answer
0
2.3kviews

Explanation

In the program below, the three numbers are stored in num1, num2 and num3 respectively. We've used the if...elif...else ladder to find the largest among the three and display it.

And Logical Operator is used to check if both the conditions are satisfied Returns True if both statements are true

if the 1st no is greater then 2nd and 3rd .Then 1st no would be largest.

elif if the 2nd no appears to largest the three Then 2nd no would be largest.

else 3rd no would be largest.

Code:-

num1=int(input("Enter first number: "))
num2=int(input("Enter second number: "))
num3=int(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
 largest = num1
elif (num2 >= num1) and (num2 >= num3):
 largest = num2
else:
 largest = num3
print("The largest number between",num1,",",num2,"and",num3,"is",largest)

Output:-

enter image description here

enter image description here

enter image description here

Please log in to add an answer.