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
- Take 3 numbers as input through the user.
- Find the largest number among three numbers using logic and if else statements.
- 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
Python program to check any person eligible to vote or not
Python program to check whether any given number is a palindrome.
Python program to check if any given string is palindrome or not.
Python program to check whether the given number is positive or not.
Python program to check whether the given number is negative or not.