In this python if else program, we will find the largest number among three numbers.
Hint:
Use nested if-else statements.
Use > operator.
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:
if num1>num3:
print(f"{num1} is the greatest")
else:
print(f"{num3} is the greatest")
else:
if num2>num3:
print(f"{num2} is the greatest")
else:
print(f"{num3} is the greatest")
Output :
Enter 1st number: 55
Enter 2nd number: 41
Enter 3rd number: 50
55 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.