189k views
2 votes
One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a number of miles as an argument and returns the number of laps. Complete the program to output the number of laps. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value))

Ex: If the input is: 2.2 the output is: 8.80 Your program must define and call the following function: def miles_to_laps(user_miles)

User Rkstar
by
5.2k points

1 Answer

1 vote

Answer:

def miles_to_laps(user_miles):

laps = user_miles / 0.25

return laps

miles = float(input("Enter number of miles: "))

print('{:.2f}'.format(miles_to_laps(miles)))

Step-by-step explanation:

Create a function named miles_to_laps that takes one parameter, user_miles

Inside the function, calculate the number of laps, divide the user_miles by 0.25 (Since it is stated that one lap is 0.25 miles). Return the laps

Ask the user to enter the number of miles

Call the function with that input and print the result in required format

User Quick
by
4.8k points