The timer shows 58 seconds at a Leeds sports day. Why does the app say ‘Keep going’?
At a school sports day in Leeds, the timer shows fifty-eight seconds. The record is sixty seconds, yet the app says ‘Keep going’. What does the app need to know about the runner before it can call that a record?
You already know how an if statement makes one decision. If the runner has finished, the app displays ‘Finished’. Otherwise, the else branch displays ‘Keep going’. The value of finished tells you which of those two paths to take.
Start with the blue finish test. Ava is still running, so she sees ‘Keep going’. Ben and Mia have finished, so follow the yes path to the purple record test. Ben’s fifty-eight seconds is below sixty, so he sees ‘Record’. Mia’s sixty-two seconds is above sixty, so she sees ‘Finished’.
This runner is still on the track. The timer shows fifty-five seconds and the record is sixty seconds. What message does the runner get? Follow the finish decision first, then pick an answer.
You just used nested selection. The finish test is the outer decision. The record test is the inner decision because it sits inside the finished branch. You only reach that inner test when the outer condition is true.
Trace a runner who has finished in fifty-nine seconds. First, finished is true, so you enter the finished branch. Next, compare fifty-nine with the sixty-second record. Fifty-nine is less than sixty, so the inner condition is true. The app displays ‘Record’.
Another runner has finished, this time in sixty-one seconds. The record is still sixty seconds. Trace both decisions in order. What does the app display for that runner? Pick the message you expect to see.
A common mistake is to pair else with the closest if above it. In Python, look at the indentation instead. An else lined up with the inner if handles a failed record test. One lined up with the outer if handles a runner who hasn't finished.
Explain the output. First, the assignments set the variables finished to true and elapsed seconds to sixty. Record seconds is a named constant, fixed at sixty. The outer condition is true. Sixty isn’t less than sixty, so the inner else calls print to display ‘Finished’. The outer else is skipped.