![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
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.
Advertisements