Software Development Exam  >  Software Development Questions  >  Write a Python program to convert height (in ... Start Learning for Free
Write a Python program to convert height (in feet and inches) to centimeters?
Most Upvoted Answer
Write a Python program to convert height (in feet and inches) to centi...
Write a Python program to convert height (in feet and inches) to centimeters. I have used python 3.7 compiler for debugging purpose.
print("Input your height: ")
1 h_ft = int(input("Feet: "))
2 h_inch = int(input("Inches: "))
3 h_inch += h_ft * 12
4 h_cm = round(h_inch * 2.54, 1)
5 print("Your height is : %d cm." % h_cm)
Community Answer
Write a Python program to convert height (in feet and inches) to centi...
Problem:

Convert height (in feet and inches) to centimeters.

Solution:

To convert height from feet and inches to centimeters, we can use the following formula:

Centimeters = (Feet * 30.48) + (Inches * 2.54)

Where:
- Feet is the height in feet
- Inches is the height in inches
- 30.48 is the conversion factor from feet to centimeters
- 2.54 is the conversion factor from inches to centimeters

Algorithm:

1. Take input for the height in feet and inches.
2. Convert the height to centimeters using the formula mentioned above.
3. Print the converted height in centimeters.

Python code:

```python
# Taking input for height in feet and inches
feet = int(input("Enter height in feet: "))
inches = int(input("Enter height in inches: "))

# Converting height to centimeters
centimeters = (feet * 30.48) + (inches * 2.54)

# Printing the converted height
print("Height in centimeters:", centimeters)
```

Explanation:

1. We start by taking user input for the height in feet and inches using the `input()` function. The `int()` function is used to convert the input to integers.
2. We then use the formula mentioned above to convert the height to centimeters. We multiply the feet by the conversion factor of 30.48 to get the height in centimeters. Similarly, we multiply the inches by the conversion factor of 2.54 to get the height in centimeters.
3. Finally, we print the converted height in centimeters using the `print()` function.

Example:

Suppose the user inputs the height as 5 feet and 8 inches.

Output:

```
Enter height in feet: 5
Enter height in inches: 8
Height in centimeters: 172.72
```

The height of 5 feet and 8 inches is equivalent to 172.72 centimeters.
Explore Courses for Software Development exam

Top Courses for Software Development

Write a Python program to convert height (in feet and inches) to centimeters?
Question Description
Write a Python program to convert height (in feet and inches) to centimeters? for Software Development 2025 is part of Software Development preparation. The Question and answers have been prepared according to the Software Development exam syllabus. Information about Write a Python program to convert height (in feet and inches) to centimeters? covers all topics & solutions for Software Development 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Write a Python program to convert height (in feet and inches) to centimeters?.
Solutions for Write a Python program to convert height (in feet and inches) to centimeters? in English & in Hindi are available as part of our courses for Software Development. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free.
Here you can find the meaning of Write a Python program to convert height (in feet and inches) to centimeters? defined & explained in the simplest way possible. Besides giving the explanation of Write a Python program to convert height (in feet and inches) to centimeters?, a detailed solution for Write a Python program to convert height (in feet and inches) to centimeters? has been provided alongside types of Write a Python program to convert height (in feet and inches) to centimeters? theory, EduRev gives you an ample number of questions to practice Write a Python program to convert height (in feet and inches) to centimeters? tests, examples and also practice Software Development tests.
Explore Courses for Software Development exam

Top Courses for Software Development

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev