Python Program to Find the Largest Among Three Numbers – 2023

Hey guys, in this blog we will see a Python Program to Find the Largest Among Three Numbers.


# Python Program to Find the Largest Among Three Numbers

num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))

if (num1 >= num2) and (num1 >= num3):
    largest = num1
elif (num2 >= num1) and (num2 >= num3):
    largest = num2
    largest = num3

print("The largest number is", largest)


Enter first number: 12
Enter second number: 14
Enter third number: 16
The largest number is 16.0
Enter first number: 0
Enter second number: 0
Enter third number: 0
The largest number is 0.0
Enter first number: 2
Enter second number: 10
Enter third number: 9
The largest number is 10.0

Here we are simply using if/else to check the conditions:

  1. If num1 is greater than num2 and num3 both, then num1 is the largest number.
  2. If num2 is greater than num1 and num3 both, then num2 is the largest number.
  3. Else num3 is the largest number.

Check out our other python programming examples

Abhishek Sharma
Abhishek Sharma

Started my Data Science journey in my 2nd year of college and since then continuously into it because of the magical powers of ML and continuously doing projects in almost every domain of AI like ML, DL, CV, NLP.

Articles: 521

Leave a Reply

Your email address will not be published. Required fields are marked *