Program to Convert Meter into Centimeter in Python | Convert CM to M in Python
Write a program to convert meter into centimeter in python, convert cm to m in python.
In this article, you will learn how to write a program to convert meter into centimeter in python programming langugae.
Example
Enter the length in centimeter::
100
Length in Meter = 1.0 meter
Length in Kilometer = 0.001 kilometer
You should have knowledge of the following topics in python programming to understand these programs:
- Python
input()
function - Python
print()
function
Standard Formula
1m = 100cm
1km = 100000cm
Source Code
# Program to Convert Meter into Centimeter in Python
print("Enter the length in centimeter::")
c, m, k = float(input()), 0, 0
# c = centimeter
# m = meter
# k = kilometer
# It will convert the centimeter into meter and kilometer values
m = (float)(c / 100)
k = (float)(c / 100000)
# It will print the final output
print("Length in Meter = ", m, " meter")
print("Length in Kilometer = ", k, " kilometer")
Output
Enter the length in centimeter::
100
Length in Meter = 1.0 meter
Length in Kilometer = 0.001 kilometer
Explanation
In this given program, we have taken input 100
from the user via the system console. Then we applied the standard formula to convert the input value into meters & kilometers.
Then this program will return these values 1.0
meters & 0.001
kilometers.