182k views
16 votes
An Olympic-size swimming pool is used in the Olympic Games, where the race course is 50 meters (164.0 ft) in length. "In swimming a lap is the same as a length. By definition, a lap means a complete trip around a race track, in swimming, the pool is the race track. Therefore if you swim from one end to the other, you’ve completed the track and thus you’ve completed one lap or one length." (Source: What Is A Lap In Swimming? Lap Vs Length)

Write the function meters_to_laps() that takes a number of meters 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:
150
the output is:
3.00
Ex: If the input is:
80
the output is:
1.60
Your program must define and call the following function:
def meters_to_laps (length)

User Ali Mizan
by
4.8k points

1 Answer

12 votes

Answer:

In Python:

def meters_to_laps(length):

lap = length/50

print('{:.2f}'.format(lap))

Step-by-step explanation:

This line defines the function

def meters_to_laps(length):

This calculates the number of laps

lap = length/50

This prints the calculated number of laps

print('{:.2f}'.format(lap))

To call the function from main, use:

meters_to_laps(150)

User Missimer
by
4.6k points