Python Program to Read Height in Centimeters and convert the Height to Feet and Inches


When it is required to read the height in ‘cm’ and convert it into ‘feet’ and ‘inches’, the ‘round’ method can be used.

Below is a demonstration of the same −

Example

 Live Demo

in_cm=int(input("Enter the height in centimeters..."))
in_inches=0.394*in_cm
in_feet=0.0328*in_cm
print("The length in inches is ")
print(round(in_inches,2))
print("The length in feet is")
print(round(in_feet,2))

Output

Enter the height in centimeters...178
The length in inches is
70.13
The length in feet is
5.84

Explanation

  • The input is taken by user, as ‘cm’.

  • It can be converted into inches by multiplying it with 0.394.

  • This is assigned to a variable.

  • It can be converted into feet by multiplying it with 0.0328.

  • This is assigned to a variable.

  • It is rounded off to nearest two decimal values.

  • Both these converted values are displayed as output on the console.

Updated on: 16-Apr-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements