Q:

Python program to convert Centimeter to Inches

belongs to collection: Python basic programs

0

write a Python code for converting the centimeters into inches.

Key: 1 inch = 2.54 cms

Example:

    Input:
    Centimeter: 245

    Output:
    Inches: 96.45669291338582    

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Python code to convert Centimeter to Inches

# Python program to convert Centimeter to Inches 
# taking input
num = float(input("Enter the distance measured in centimeter : "))

# converting from cms to inches
""" 1 inch = 2.54 centimeters"""
inc = num/2.54 

# printing the result
print("Distance in inch : ", inc)

Output

First run:
Enter the distance measured in centimeter : 245
Distance in inch :  96.45669291338582

Second run:
Enter the distance measured in centimeter : 54
Distance in inch :  21.25984251968504 

Third run:
Enter the distance measured in centimeter : 2.54
Distance in inch :  1.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to convert meters into yards... >>
<< Python program Tower of Hanoi (modified)...