At a Leeds arcade, can one scoring instruction award points for all five targets?
At a Leeds arcade, you hit all five targets, and each hit earns two points. The game has to add those points to your score. Can you write the scoring instruction once and still make it run five times?
You can follow this sequence from top to bottom. First set the score to zero. Then each scoring line adds two. Watch the score change to two, four, six, eight and ten. Each of the five copies runs once.
Start the score at zero as before. Watch the hit counter take the values one, two, three, four and five. For each value, the same scoring line adds two. That's a count-controlled for loop. Its body runs once for each counter value.
If you pause just after the scoring line runs for the third time, what value does the hit counter hold? Pick the counter value. The score is a different variable.
Compare the two rows. In AQA pseudocode, one to five includes five. In Python, range with a start of one and a stop of six gives the same values. Python includes the start and stops before the second number.
For turns three to six, list three, four, five and six. Add one to six to get Python's stop. Write range with three and seven, then indent the scoring line so it runs inside the loop. Seven take away three gives four runs, matching your list.
Now your AQA loop runs from four to eight. Pick the Python range that visits exactly the same counter values. Before you choose, count how many values you need, including four and eight.
On the left, copying eight into Python's stop leaves out the turn numbered eight. You get four runs instead of five. On the right, the stop is nine, so the counter reaches eight and the scoring line runs all five times.
What is the value of score after the algorithm has finished executing? The score starts at ten. Points per hit names the fixed award of three. Trace hits two through five. The score changes to thirteen, sixteen, nineteen and finally twenty-two.