Write A Python Program To Convert Centimeters To Inches

Hi Guys, welcome to my blog in this article you will learn about how to Write A Python Program To Convert Centimeters To Inches

 

Title : 

Write A Python Program To Convert Centimeters To Inches


Write A Python Program To Convert Centimeters To Inches



 

Description : 

Hey guys in this article you will learn a white on program that takes an input as centimetres and then convert into inches. We will be performing the floating point division operation, In order to convert the centimetres to inches you should know the below formula. inches = centimeters / 2.54 Use the input function call and ask a user to enter length in centimetres and then convert it into a floating point number.


    
centimeters = float(input("Enter length in centimeters: "))



    


Now use the above formula and divide the centimetres by 2.54, store this value into another variable named as inches and use the print function call to print the inches.


    

inches = centimeters / 2.54

print("{:.2f} centimeters is equal to {:.2f} inches".format(centimeters, inches))


    




Complete Python Code : 


    
centimeters = float(input("Enter length in centimeters: "))

inches = centimeters / 2.54

print("{:.2f} centimeters is equal to {:.2f} inches".format(centimeters, inches))


    

 

 

Output : 


    
Enter length in centimeters: 33
33.00 centimeters is equal to 12.99 inches


    

 

Output : 


    
Enter length in centimeters: 20
20.00 centimeters is equal to 7.87 inches


    



Conclusion :

The above Python program Ask the user to enter the floating point value that is centimetres, uses the division operation to convert it into inches and finally print it. Comment it down below if you have any suggestions to improve the above Python program

 

Post a Comment

0 Comments