Python Program to Convert Centimeters to Feet and Inches

This is a Python Program to read height in centimeters and then convert the height to feet and inches

Problem Description

The program reads the height in centimeters and then converts the height to feet and inches.

Problem Solution

1. Take the height in centimeters and store it in a variable.
2. Convert the height in centimeters into inches and feet.
3. Print the length in inches and feet.
4. Exit.

Program/Source Code

Here is source code of the Python Program to Calculate the Average of Numbers in a Given List. The program output is also shown below.

 
cm=int(input("Enter the height in centimeters:"))
inches=0.394*cm
feet=0.0328*cm
print("The length in inches",round(inches,2))
print("The length in feet",round(feet,2))
Program Explanation

1. User must enter the height in centimeters.
2. The height in centimeters is multiplied by 0.394 and stored in another variable which now contains the height in inches.
3. The height in centimeters is multiplied by 0.0328 and stored in another variable which now contains the height in feet.
4. The converted height in inches and feet is printed.

advertisement
advertisement
Runtime Test Cases
 
Case 1:
Enter the height in centimeters:50
The length in inches 19.7
The length in feet 1.64
 
Case 2:
Enter the height in centimeters:153
The length in inches 60.28
The length in feet 5.02

Sanfoundry Global Education & Learning Series – Python Programs.

To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.

Note: Join free Sanfoundry classes at Telegram or Youtube

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.