Exam preparation · GCSE · about 20 min
Taking a question apart, the jobs that come up again and again, and how the marks are given.
[1 mark]You cannot finish a programming question. What is the best thing to do?
[1 mark]Which of these earns marks in a written programming answer?
[1 mark]A question says to reject an input over 60. What is that worth?
[1 mark]What does this program print?
done = 0
steps = 0
while done < 32:
step = min(7, 32 - done)
done = done + step
steps = steps + 1
print(steps, done)5 32
Four steps of 7 and a last step of 4.
[1 mark]What should you do before writing any code in a long question?
Write the program for this question. The robot must drive far centimetres in steps of step centimetres, where the last step is whatever is left over. After each step, print so far: <n> cm. At the end print steps: <n> and total: <n> cm. Use the values given; do not type the answers.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() far = 32 step = 7
The hint students can ask for: Keep a running total of how far you have driven and loop while it is less than the target. Each step is the step size, or whatever is left if that is smaller. Count the steps as you go.
from bugbot import *
connect()
far = 32
step = 7
done = 0
count = 0
while done < far:
this = min(step, far - done)
forward(50, distance=this)
done = done + this
count = count + 1
print(f"so far: {done} cm")
print("steps:", count)
print(f"total: {done} cm")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.