Editor

Pseudocode runners

Run pseudocode in the style your exam board uses, and see the line where it goes wrong.

The same ideas in each style

IdeaCambridgeOCRCSP reference sheetPython
Store a value
Total ← 0
total = 0
total ← 0
total = 0
Show a value
OUTPUT Total
print(total)
DISPLAY (total)
print(total)
Read input
INPUT Name
name = input("Name? ")
name ← INPUT ()
name = input("Name? ")
Equal, not equal
=   <>
==   !=
=   ≠
==   !=
Decide
IF X > 0 THEN
    ...
ENDIF
if x > 0 then
    ...
endif
IF (x > 0)
{
   ...
}
if x > 0:
    ...
Count
FOR I ← 1 TO 10
    ...
NEXT I
for i = 1 to 10
    ...
next i
REPEAT 10 TIMES
{
   ...
}
for i in range(1, 11):
    ...
Loop while
WHILE X < 10 DO
    ...
ENDWHILE
while x < 10
    ...
endwhile
REPEAT UNTIL (x ≥ 10)
{
   ...
}
while x < 10:
    ...
First array indexAs declared, often 1
0
1
0
Remainder
X MOD 2
x MOD 2
x MOD 2
x % 2
Join text
"Hi " & Name
"Hi " + name
(no operator)
"Hi " + name
Function
FUNCTION Sq(N : INTEGER) RETURNS INTEGER
    RETURN N * N
ENDFUNCTION
function sq(n)
    return n * n
endfunction
PROCEDURE sq (n)
{
   RETURN (n * n)
}
def sq(n):
    return n * n

Frequently asked questions

What is pseudocode?
A way of writing an algorithm step by step in structured English, close enough to code that it could be turned into a program, without the details of any one programming language.
Is there one correct way to write pseudocode?
No. Each exam board publishes its own style, and an exam answer should use the board's style. Outside exams, any clear and consistent style is fine.
Can pseudocode actually run?
Only when its rules are written down exactly, as the exam boards do. These runners follow each board's published rules, translate the program into Python and run it in your browser.
How do I turn a Python program into pseudocode?
Paste it into the Python to pseudocode converter, which writes it as plain English, Cambridge-style pseudocode, reference-sheet pseudocode or numbered steps. The Python to flowchart tool draws the same program as a flowchart.

More: Python to pseudocode · Python to flowchart · Computer Science Principles course · Python lessons

Cambridge IGCSE, Cambridge O Level and Cambridge International AS & A Level are qualifications of Cambridge University Press & Assessment, which is not affiliated with this site and does not endorse it.

OCR (Oxford Cambridge and RSA Examinations) publishes the Exam Reference Language for GCSE Computer Science J277. OCR is not affiliated with this site and does not endorse it.

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