The answersDownload the PDF
Worksheet

F5.3 Pseudocode and the exam reference language

Algorithms · GCSE · OCR J277 2.1.2, AQA 8525 3.1.1, Edexcel 1CP2 1.2.2 · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Reading and writing your board's pseudocode, and translating it into Python.

Questions 5 marks in all

  1. [1 mark]What is pseudocode?

    1. AA way of writing an algorithm that looks like code but is not tied to one language
    2. BA programming language that runs on robots
    3. CCode with errors in it
    4. DComments in a program
  2. [1 mark]What is 17 MOD 5 in Python? Write the Python expression.

  3. [1 mark]for i = 1 to 5 in OCR's Exam Reference Language. How many times does the loop run?

  4. [1 mark]Which Python line is the same as AQA's x ← x + 1?

    1. Ax = x + 1
    2. Bx == x + 1
    3. Cx <- x + 1
    4. Dx + 1 = x
  5. [1 mark]Which Python loop is the same as for i = 1 to 4?

    1. Afor i in range(1, 5):
    2. Bfor i in range(1, 4):
    3. Cfor i in range(4):
    4. Dfor i in range(0, 4):

The task: steps from pseudocode

Translate the algorithm at the top of this lesson into Python, from the pseudocode for your board. The robot should step towards the wall in 10 cm steps while it is more than 30 cm away, then print whether it took an even or odd number of steps, in exactly the form even number of steps: 4.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

steps = 0

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

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

Challenges

  1. Write pseudocode for the password guard from lesson F5.2, in your board's style.
  2. Translate this OCR loop into Python, and check it prints the same numbers: for i = 2 to 10 step 2 then print(i) then next i.
  3. Find three things in a Python program of yours that would need changing to be good pseudocode for your board.