Python program to find largest of three numbers

Subject: Python Programming

Contributed By: Nunugoppula Ajay

Created At: February 24, 2025

Question:


Write a Python program to find largest of three numbers.

Explanation Video:

Custom Image

Explanation:

The output of this straightforward Python program is the largest of three provided numbers.

Using an input function, we first gather user input for three integers that need to be compared.  
num1=int(input("Enter 1st number : "))
num2=int(input("Enter 2nd number : "))
num3=int(input("Enter 3rd number : "))

Then, we simply use relational operator ‘>’ in the if-elif-else block to determine which of the three provided numbers is the greatest.
if num1>num2 and num1>num3:
         print(num1,"is the Largest Number")
elif num2>num1 and num2>num3:
         print(num2,"is the Largest Number")
else:
        print(num3, "is the Largest Number")

Source Code:
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(num1,"is the Largest Number")
elif num2>num1 and num2>num3:
    print(num2,"is the Largest Number")
else:
    print(num3, "is the Largest Number")
Input:
Enter 1st number : 12
Enter 2nd number : 10
Enter 3rd number : 14
Output:
14 it the Largest Number
Share this Article & Support Us:
Status
printf('Loading...');