Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Two cyclists, Asha and Ravi, have these distances in metres at 0, 1, 2, 3, 4 and 5 minutes.
Asha: 0, 150, 330, 480, 650, 800. Ravi: 0, 100, 230, 330, 430, 540.
Draw one graph with both lines, with a title, labels with units, a legend and a grid. Then use the arrays to find how far ahead Asha is after each minute, in which minute the gap grows the most, and the average speed of each cyclist over the five minutes.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Two lines on one graph, each with a label. The gap is one array minus the other. The growth of the gap in each minute is np.diff of the gap.
Check. The gap is 0, 50, 100, 150, 220, 260. The growth in each minute is 50, 50, 50, 70, 40, so the biggest growth, 70 m, is in the 4th minute. The average speeds are m/min and m/min.
Answer: the gaps are [0 50 100 150 220 260] m, the gap grows the most in minute 4, and the average speeds are 160 and 108 m/min.
Log in to join the discussion.
Loading…