HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /A long scenario question. At a sports day, six runners each run 100 metres…
HardComputer ScienceHigh School (9–10)Computer Science › ProgrammingcodingIGCSE

A long scenario question. At a sports day, six runners each run 100 metres…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

A long scenario question. At a sports day, six runners each run 100 metres. Write a program that:

  • inputs the time of each runner in seconds, as a REAL value;
  • rejects any time below 9.0 or above 30.0 and asks for it again, with a message;
  • finds the fastest time and the average time, rounded to 2 decimal places;
  • counts how many runners finish in under 15.0 seconds;
  • outputs the three results with suitable messages.

Use constants for the number of runners and the 15.0 seconds. You may answer in pseudocode or Python. Then dry-run it for the typed times 16.4, 14.2, 35.0, 13.8, 15.0, 17.9 and 14.9.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

FOR Count ← A TO B STEP S ... NEXT Count runs a known number of times. WHILE <condition> DO ... ENDWHILE tests first and may run no times. REPEAT ... UNTIL <condition> tests last and runs at least once. A total adds each value; a count adds 1. A trace table records every variable and output at each step.

The worked solution

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.

A model answer in pseudocode.

pseudocode
CONSTANT Runners ← 6
CONSTANT Qualify ← 15.0
DECLARE Runner : INTEGER
DECLARE Time : REAL
DECLARE Total : REAL
DECLARE Fastest : REAL
DECLARE Qualified : INTEGER
Total ← 0.0
Qualified ← 0
FOR Runner ← 1 TO Runners
    REPEAT
        OUTPUT "Time for runner ", Runner
        INPUT Time
        IF Time < 9.0 OR Time > 30.0
          THEN
            OUTPUT "Time out of range"
        ENDIF
    UNTIL Time >= 9.0 AND Time <= 30.0
    Total ← Total + Time
    IF Runner = 1
      THEN
        Fastest ← Time
      ELSE
        IF Time < Fastest
          THEN
            Fastest ← Time
        ENDIF
    ENDIF
    IF Time < Qualify
      THEN
        Qualified ← Qualified + 1
    ENDIF
NEXT Runner
OUTPUT "Fastest time ", Fastest
OUTPUT "Average time ", ROUND(Total / Runners, 2)
OUTPUT "Runners under ", Qualify, " seconds ", Qualified

The dry run. The time 35.0 is rejected, so runner 3 is asked again and types 13.8. The six accepted times are 16.4, 14.2, 13.8, 15.0, 17.9 and 14.9. Their total is 92.2, so the average is 92.2÷6=15.3666…92.2 \div 6 = 15.3666\ldots92.2÷6=15.3666…, which rounds to 15.37. The fastest is 13.8. The times under 15.0 are 14.2, 13.8 and 14.9, so the count is 3. The time 15.0 itself is not under 15.0.

How such an answer is marked. One mark for each point, up to 15:

  1. Constants declared, with meaningful names.
  2. Variables declared with suitable types.
  3. Total and count set to zero before the loop.
  4. A loop that runs once for each runner.
  5. A prompt and input of the time inside the loop.
  6. A validation loop around the input.
  7. The correct range check, 9.0 to 30.0, both included.
  8. An error message for a rejected time.
  9. Each accepted time added to the total.
  10. The fastest time set from the first runner.
  11. The fastest time replaced when a smaller time comes.
  12. The count increased when a time is under 15.0.
  13. The average worked out after the loop and rounded.
  14. The three results output with messages.
  15. Comments or clear layout that make the program readable.

Watch out. Working out the average inside the loop, or setting the total to zero inside it, are the two most common slips.

Log in to save this for later
← All Problems
← This pseudocode works on a whole number that is input…A program draws borders of stars with a procedure… →
More onComputer Science › Programming

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Loops, totals, counts and nested statementsVariables, Selection and Loops in Pseudocode

More on this topic

  1. A long scenario question. A teacher has the names of 5 students in the file Names.txt, one name a…Hard
  2. Shopping.txt holds six lines: bread, rice, milk, eggs, tea and jam…Medium
  3. The file Best.txt holds one line: 120. What is output, and what does Best.txt hold afterwards, when…Easy
The nine squares of a board are input row by row: X, O, O, then X, X, X, then O, a dot for an empty…Hard
  • Three teams play three games each. Points[Team, Game] holds the points of a team in a game…Medium
  • All problems on this topic →