In this post, we are going to see how to convert Kms to Miles using a simple Python script. The formula for converting Kilometer to Miles is very simple, just dividing the value by 1.609.
Let’s write the program now,
#get the Kilometer from user
print ("Enter km")
km = float(input())
#convert km to miles
miles = km / 1.609
print ("Miles: %0.4f" %miles)
Sample output of the above program:
Enter km: 10 Miles: 6.2150
It’s very simple, right? Hope this post is useful for you. Thanks.