program to find the largest of three numbers in python 1

program to find the largest of three numbers in python

##Write a Python program to input 3 numbers and find the largest. 
##Print all the numbers, and the  largest among them, with appropriate titles.  

n1=float(input("Enter number 1: "))
n2=float(input("Enter number 2: "))
n3=float(input("Enter number 3: "))
if n1 > n2 :
 if n1 > n3 :
     LNo=n1
 else :
     LNo=n3
else :
 if n2 >n3 :
     LNo=n2
 else :
     LNo=n3
print("DISPLAY........")
print("Number 1 : ",n1)
print("Number 2 : ",n2)
print("Number 3 : ",n3)
print("Largest number is : ",LNo) 

Here is what the above code is Doing:
1. It is taking 3 inputs from the user and storing them in 3 variables.
2. It is comparing the first two numbers and storing the larger one in a variable.
3. It is comparing the third number with the larger of the first two numbers and storing the larger one in a variable.
4. It is printing all the numbers and the largest number.

Similar Posts