Articles

Python program to find largest of three numbers

Python program to find largest of three numbers


In this Python programming guide, we will learn:

  • program to find the largest of three numbers in python

Program to find greatest of three numbers in python

The program to find greatest of three numbers in python is as follows:

 

# Owner : TutorialsInhand Author : Devjeet Roy

n1 = float(input("Enter first number: "))
n2 = float(input("Enter second number: "))
n3 = float(input("Enter third number: "))
 
if (n1 > n2) and (n1 > n3):
   largest = n1
elif (n2 > n1) and (n2 > n3):
   largest = n2
else:
   largest = n3
 
print("The largest number is",largest)

The output of program to find greatest of three numbers in python is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter first number: 12
Enter second number: 23
Enter third number: 11 
The largest number is 23.0

Few important tips about this program

1. First of all, we ask the user to enter three numbersand we convert each one of them to float data type.

2. Thereafter we have used comparison operator to compare the numbers and find the largest one.

 

Snapshot of program to find largest of three numbers in python:

program to find largest of three numbers in python

 


Python Numbers Program

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Dec 30,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!