Editor

Pseudocode runner

Part of Computer Science Principles in Python

Type the exam's reference-sheet pseudocode and run it, to check what a question's code really displays.

Type <- for ←, != for ≠, <= for ≤ and >= for ≥ if you prefer the keyboard. Ctrl+Enter runs.

The rules it follows

Lists start at 1
aList[1] is the first element. Index 0, a negative index or one past the end stops the program with an error, as on the exam.
DISPLAY keeps to one line
Each value is followed by a space, so several DISPLAY calls print side by side.
Assigning a list copies it
After bList ← aList, changing aList leaves bList as it was.
REPEAT UNTIL checks first
The condition is tested before each pass, so the body can run zero times.
RANDOM(a, b) includes both ends
RANDOM(1, 3) gives 1, 2 or 3.
The robot stops the program
Moving into a blocked square or off the grid leaves the robot where it is and ends the program.

Every construct next to its Python equivalent is in the lesson Exam Pseudocode in Python.

AP® and Advanced Placement® are trademarks registered by the College Board, which is not affiliated with, and does not endorse, this website.