The worksheetDownload the PDF
Answers

F13.3 Pseudocode in the exam

Exam preparation · GCSE · about 15 min

BugBotLab

What this lesson is about

Reading and writing exam pseudocode and flowcharts, and translating both ways.

Questions 5 marks in all

  1. [1 mark]How many times does FOR i = 1 TO 5 run?

    1. A5
    2. B4
    3. C6
    4. DIt depends on the board
    Answer: A. The end value is included, unlike range(1, 5) in Python.
  2. [1 mark]Which pseudocode keyword prints something?

    Answer: OUTPUT. OUTPUT is print.
  3. [1 mark]In a flowchart, what does a diamond mean?

    1. AA decision
    2. BA process
    3. CInput or output
    4. DThe start
    Answer: A. Each way out of a diamond is labelled.
  4. [1 mark]What does this program print?

    for i in range(1, 4):
        print(i * i)
    Answer:
    1
    4
    9

    FOR 1 TO 3 includes 3, so range stops at 4.

  5. [1 mark]You are asked to write an algorithm. What may you use?

    1. APseudocode or a real language, as long as it is clear
    2. BOnly your board's reference language
    3. COnly Python
    4. DOnly a flowchart
    Answer: A. The logic earns the marks, not the syntax.

The task: pseudocode into Python

Turn the pseudocode in the comment into a working program. It asks for a number of steps, drives that many 10 cm steps while counting the total distance, and prints the total. input() is answered for you with 4.

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

# steps = USERINPUT
# total = 0
# FOR i = 1 TO steps
#     MOVE FORWARD 10
#     total = total + 10
#     OUTPUT "step " + i + ": " + total
# NEXT i
# OUTPUT "total: " + total

The hint students can ask for: The answer from input() is text, so make it a whole number first. FOR 1 TO steps includes the last one, so the range has to reach one past it. Add the 10 on before you print.

A solution

from bugbot import *
connect()
steps = int(input())
total = 0
for i in range(1, steps + 1):
    forward(50, distance=10)
    total = total + 10
    print(f"step {i}: {total}")
print("total:", total)

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.