KnowledgeBoat Logo

Computer Science

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).

Python

Python Funda

139 Likes

Answer

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

Answered By

63 Likes


Related Questions