Find the largest number among three numbers.

In this Python if-else program, we will find the largest number among three numbers.

Hint:
Use an elif condition to check the number value.

Steps to solve the program

  1. Take 3 numbers as input through the user.
  2. Find the largest number among three numbers using logic and if else statements.
  3. Print the output.
				
					num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
num3 = int(input("Enter 3rd number: "))

if num1 > num2 and num1 > num3:
    print(f"{num1} is the greatest")
elif num2>num1 and num2 > num3:
    print(f"{num2} is the greatest")
elif num3>num1 and num3 > num2:
    print(f"{num3} is the greatest")
else:
    print("No number has greater value")

				
			

Output :

				
					Enter 1st number: 50
Enter 2nd number: 40
Enter 3rd number: 79
79 is the greatest
				
			

Related Articles

determine whether a given number is available in the list

check any person eligible to vote or not

Leave a Comment