The answersDownload the PDF
Worksheet

F13.4 Programming questions

Exam preparation · GCSE · about 20 min

BugBotLab
NameClassDate

What this lesson is about

Taking a question apart, the jobs that come up again and again, and how the marks are given.

Questions 5 marks in all

  1. [1 mark]You cannot finish a programming question. What is the best thing to do?

    1. AWrite what is left as comments or pseudocode
    2. BLeave it blank
    3. CRub out what you have
    4. DCopy an earlier answer
  2. [1 mark]Which of these earns marks in a written programming answer?

    1. AMeaningful variable names and clear structure
    2. BVery short variable names
    3. CNo comments at all
    4. DPerfect punctuation
  3. [1 mark]A question says to reject an input over 60. What is that worth?

    1. AA mark: handle the failure case
    2. BNothing
    3. COnly if the program runs
    4. DA mark only in an on-screen exam
  4. [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. [1 mark]What should you do before writing any code in a long question?

    1. AUnderline the inputs, outputs and rules
    2. BWrite the last line first
    3. CChoose variable names for everything
    4. DCount the marks

The task: an exam-style program

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

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/f13-4-programming-questions/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Change far to 30 and step to 5. Does your program still print the right number of steps?
  2. Add validation: refuse a step of 0 and say why, instead of looping forever.
  3. Rewrite it with a for loop instead of a while loop. Which reads better here?