Python program to convert kilometers to miles
In this python programming guide, we are going to learn-
-
program to convert kilometers to miles in python
Program to convert Kilometers to Miles in Python
The program to convert kilometers to miles in python is as follows:
# Owner : TutorialsInhand Author : Devjeet Roy
kms = int(input("Enter length in KMs: "))
miles = kms/1.609
print("The length in miles is",round(miles,3))
The output of program to convert kilometers to miles in python is as follows:
PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter length in KMs: 23
The length in miles is 14.295
Few important tips about the program:
1. In the program, we take the user input in and convert it to integer data type.
2. Then we convert the KMs to Miles as 1 Miles = 1.609 KMs.
3. At the end, we round off the number to 3 decimal places using the round() function.
Write a python program to convert kilometers to miles snapshot:
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Devjeet Roy
Full Stack Web Developer & Data Science Enthusiast
Page Views :
Published Date :
Feb 09,2021