By completing this challenge we are learning how to open and extract data from a text file, reading the file line by line. We will then use our program to make some calculations such as calculating the total distance of the race over 21 stages.
Le Tour de France is a cycling race that takes place over 21 stages (23 days in total, including two rest days). The text file below contains a list of the 21 stages as follows (based on the 2015 route):
Adapt this code to answer the following questions:
- What stage is the longest stage (in distance)?
- What stage is the shortest stage (in distance)?
- What is the average distance per stage?
- What is the total distance of the race in miles?
- Between stage 16 and stage 17, once in Gap, cyclists have a rest day. How many kilometres have they been cycling for? How many kilometres are left till the end of the race?
Solution...The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area