In this challenge you are going to write a Python script to help a marathoner predict the overall time they can complete a Marathon in (42km).
This estimation will be based on the runner’s pace which is the time they take to run 1km.
For instance:
- Runner A runs 1km in 5:25 (5 minutes and 25 seconds)
- Runner B, who is slower, runs 1km in 6:10 (6 minutes and 10 seconds)
Your Python script will:
- INPUT: Ask the runner for their pace (e.g. 5:25),
- PROCESS: Convert this input into a number of seconds: e.g. 5:25 = 5 * 60 + 25 = 325 seconds,
- PROCESS: Multiply this total by 42 as there are 42km in a Marathon,
- PROCESS: Convert this new total using the hh:mm:ss format. (e.g 3:47:30)
- OUTPUT: Display this new total on screen (using the hh:mm:ss format). (e.g 3:47:30)
Flowchart
The following flowchart describes the main steps of our algorithm based on the
Input > Process > Output model:
Your Solution
Code your solution to this challenge:
Step by Step Solution:
The 5 steps described above are solved to help you complete this challenge step by step:
Testing
Now that you have implemented your solution you may want to test it by completing the following test plan: (this test plan is based on a length of 42km)
Test # | Input Values | Expected Output | Actual Output |
#1 | Pace: 5:25 | 3:47:30 | |
#2 | Pace: 6:10 | 4:19:00 | |
#3 | Pace: 4:00 | 2:48:00 | |
#4 | Pace: 2:55 (Close to World Record) | 2:02:30 |
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area