1 mile is equal to 1.60934 kilometers.
def miles_to_kilometers(miles):
return miles * 1.60934
# Taking input for miles and converting them to kilometers
def convert_and_display_miles_to_kilometers():
miles = float(input("Enter the distance in miles: "))
kilometers = miles_to_kilometers(miles)
print("Distance in kilometers:", kilometers)
convert_and_display_miles_to_kilometers()
Enter the distance in miles: 10
Distance in kilometers: 16.0934
Enter the distance in miles: 25
Distance in kilometers: 40.2335
The function miles_to_kilometers(miles)
converts miles to kilometers using the conversion factor.
The function convert_and_display_miles_to_kilometers()
takes input for miles, converts them to kilometers using the aforementioned function, and displays the result.