CBSE Class 11 Computer Science Question 99 of 106

Python Fundamentals — Question 8

Back to all questions
8
Question

Question 8

Write a short program that asks for your height in centimetres and then converts your height to feet and inches. (1 foot = 12 inches, 1 inch = 2.54 cm).

Solution
ht = int(input("Enter your height in centimeters: "))
htInInch = ht / 2.54;
feet = htInInch // 12;
inch = htInInch % 12;
print("Your height is", feet, "feet and", inch, "inches")
Output
Enter your height in centimeters: 162
Your height is 5.0 feet and 3.7795275590551185 inches
Answer