Challenge 2: Slug race
Suggested time: 25 minutes
A student wanted to find out which animal is fastest out of slugs and snails and so recorded the results of a slow animal race.
The student measured how far each animal slithered or crawled and timed how long it took for them to move that distance.
The student needs a program to calculate the speed of each animal and display it in a table as shown below:
The distance each animal travelled was measured in metres and is recorded in a data structure in the code below.
The program should calculate the speed in centimetres per second.
There are 100cm (centimetres) in 1m (metre)
Speed can be calculated by dividing distance travelled by the time taken to travel that distance.
Using the file Q05.py below:
Amend the program to:
- read the name, distance and times for each animal from the data structure,
- calculate the speed for each animal
- display the results in a table as shown above
Do not add any additional functionality
Use comments, whitespace and layout to make the program easier to read and understand
If this was a real question it would tell you to save your code as Q05_FINISHED.py but you might want to save your code so you can show your teacher or come back to it later by pressing Ctrl + S or clicking on the icon that looks like this: