Algorithms · GCSE · OCR J277 2.1.2, AQA 8525 3.1.1, Edexcel 1CP2 1.2.2 · about 15 min
Reading and writing your board's pseudocode, and translating it into Python.
[1 mark]What is pseudocode?
[1 mark]What is 17 MOD 5 in Python? Write the Python expression.
[1 mark]for i = 1 to 5 in OCR's Exam Reference Language. How many times does the loop run?
[1 mark]Which Python line is the same as AQA's x ← x + 1?
x = x + 1x == x + 1x <- x + 1x + 1 = x[1 mark]Which Python loop is the same as for i = 1 to 4?
for i in range(1, 5):for i in range(1, 4):for i in range(4):for i in range(0, 4):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.
for i = 2 to 10 step 2 then print(i) then next i.