# Average Lap Time Calculator

An Athletics club is planning to create an app to record the lap time of different runners during a 400 x 4 relay race. Their app will capture and store the names of the runners involved in the relay race and record the lap times of each runner.

Their app will then be used to generate more information using the recorded data such as:

• The overall time it took for the runners to complete the relay race.
• The average lap time calculated using the recorded lap times of each runner.

In the code provided below, you will find that the names and lap times of each runner are stored in the code using two lists called names and times.

```runners = ["Alina","Rafael","Sid","Suraya"]
times = ["1:24","1:45","1:33","1:39"]
```

In the times list, lap times are expressed in minutes:seconds. For instance Alina completed her lap in 1 minute and 24 seconds whereas Rafael completed his lap in 1 minute and 45 seconds.

Then the following code is used to loop through each values in each list to display the lap time of each runner.

```#Retrieve the number of runners involved in the race (e.g. 4)
numberOfRunners = len(runners)

for i in range(0,numberOfRunners):
print(runners[i] + " completed a lap in " + times[i])
```

Your task will be to complete the code provided below so that your Python program automatically calculates the overall time it took these 4 runners to complete the 4 x 400m relay to then work out the average lap time amongst these four runners. Make sure the overall time and the average time are given in the minutes:seconds format.

#### Tip?

Revealing this tip is optional! Only reveal it if you are not sure how to get started with this task!

View Tip!
To complete this task, you will first need to convert the given lap times in seconds. For instance a lap time of 1:24 means that the lap was completed in 60 + 24 = 84 seconds.

So in the for loop provided we can easily work out the lap time of each runner in seconds as follows:

```for i in range(0,numberOfRunners):
print(runners[i] + " completed a lap in " + times[i])

#convert lap time in a number of seconds
data = times[i].split(":")
minutes = int(data[0])
seconds = int(data[1])
lapTime = minutes * 60 + seconds

print(runners[i] + " completed a lap in " + str(laptime) + "seconds")
```

#### Python Code

Complete the code below…

#### Solution...

The solution for this challenge is available to full members!
Find out how to become a member:

Did you like this challenge?

Click on a star to rate it!

Average rating 3.1 / 5. Vote count: 35

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!