Convert human height in centimeters
Write a program in python that reads a number of feet from the user, followed by a number of inches. After that program should compute and display the equivalent number of centimeters.
Hint: One foot is 12 inches. One inch is 2.54 centimeters
Hint: One foot is 12 inches. One inch is 2.54 centimeters
## #Python's program to convert height in feet and inches to centimeters. ## #Define the constants CEN_IN_FEET = 12 CEN_IN_INCH = 2.54 #Read the input(height) from human print("Enter your height:") feet = int(input(" Number of feet: ")) inches = int(input(" Number of inches: ")) #Convert the input in equivaltent centimeters centimeters = (feet * CEN_IN_FEET + inches) * CEN_IN_INCH #Display the result print("Your height in centimeters is:",centimeters)
Sample output of above program.
C:\Python\programs>python program3.py
Enter your height:
Number of feet: 5
Number of inches: 4
Your height in centimeters is: 162.56
C:\Python\programs>
Enter your height:
Number of feet: 5
Number of inches: 4
Your height in centimeters is: 162.56
C:\Python\programs>
2017-08-25T11:10:57+05:30
2017-08-25T11:10:57+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution