Find the Largest Among Three Numbers

In this Python lesson, we will practice how to find the largest among three numbers.

Example: Find the Largest Number using if-else Condition

# Request different inputs from user
num1 = float(input('Enter first number: '))
num2 = float(input('Enter second number: '))
num3 = float(input('Enter third number: '))

if (num1 >= num2) and (num1 >= num3):
   bigNum = num1
elif (num2 >= num1) and (num2 >= num3):
   bigNum = num2
else:
   bigNum = num3

print('The largest number = {0}'.format(bigNum))

Output

Enter first number: 67
Enter second number: 54
Enter third number: 23

The largest number = 67.0

In the above program, we requested the user to insert three different numbers which were stored in the variables of num1num2 and num3. The largest number is determined using the if…elif…else condition.

To get more different results, change the values of num1num2 and num3.

Do you want to become an expert programmer? See books helping our students, interns, and beginners in software companies today (Click here)!

Leave a Comment

Python Tutorials