Introduction
In this challenge, you will write a Python function to convert miles to kilometers. You will be given a distance in miles and you need to return the equivalent distance in kilometers.
In this challenge, you will write a Python function to convert miles to kilometers. You will be given a distance in miles and you need to return the equivalent distance in kilometers.
Write a Python function called miles_to_km
that takes a parameter miles
(a float or an integer) and returns the equivalent distance in kilometers. You should use the following conversion formula: km = mi * 1.609344
.
def miles_to_km(miles):
return miles * 1.609344
miles_to_km(5.03) ## 8.09500032
In this challenge, you learned how to convert miles to kilometers using a Python function. You should now be able to take any distance in miles and convert it to kilometers using the formula km = mi * 1.609344
.