Python Program to Convert Kilometers to Miles
Jun 18, 2021
Hi Guys,
In this blog, I would like to share with you how to convert kilometers to miles using python. We will show how to get kilometers to miles in python. I am share with you python program to convert km(kilometers) to miles.
Here i will give example of how to convert kilometers to miles using python program so let's see the below example:
Example:
mile.py
# get kilometers input from the user
kilometers = float(input("Enter value in kilometers: "))
# conversion factor
conv_fac = 0.621371
# calculate miles
miles = kilometers * conv_fac
print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
Output
Enter value in kilometers: 3.5
3.50 kilometers is equal to 2.17 miles
It will help you....
- Get Last 2 Digits of Number in Python Tutorial Example
- How to Sum of First and Last Digit of Number in Python?
- How to Get First and Last Digit of Number in Python?
- Get the Last Digit of Number in Python Tutorial Example
- Get the First Digit of Number in Python Tutorial Example
- How to Remove All Decimals from Number in Python?
- How to Convert String to Float with 2 Decimal Places in Python?
- How to Format Number to 2 Decimal Places in Python?