Python → Pseudocode
Paste Python and get instant OCR, AQA or CIE exam-board pseudocode.
GCSE & A-Level
OCR J277
AQA 8525
CIE 0478 / 9618
No server. No login.
Loading Python engine...
Python
Edit your code here
OCR Pseudocode
J277 Exam Reference Language
Loading Python engine (first visit only, ~5 seconds)...
Quick Reference: Python vs OCR vs AQA vs CIE
▼
| Construct | Python | OCR ERL | AQA | CIE |
|---|---|---|---|---|
| Assignment | x = 5 |
x = 5 |
x ← 5 |
x ← 5 |
| Output | print(x) |
print(x) |
OUTPUT x |
OUTPUT x |
| Input | x = input("p") |
x = input("p") |
OUTPUT "p" |
OUTPUT "p" |
| Comment | # note |
// note |
# note |
// note |
| Not equal | != |
!= |
≠ |
<> |
| Equal | == |
== |
= |
= |
| If | if x: |
if x then / endif |
IF x THEN / ENDIF |
IF x THEN / ENDIF |
| For loop | for i in range(5): |
for i = 0 to 4 / next i |
FOR i ← 0 TO 4 / ENDFOR |
FOR i ← 1 TO 5 / NEXT i |
| While loop | while x: |
while x / endwhile |
WHILE x / ENDWHILE |
WHILE x DO / ENDWHILE |
| Function | def f(x): |
function f(x) / endfunction |
SUBROUTINE f(x) / ENDSUBROUTINE |
FUNCTION f(x) RETURNS <type> / ENDFUNCTION |
| Procedure | def f(x): # no return |
procedure f(x) / endprocedure |
SUBROUTINE f(x) / ENDSUBROUTINE |
PROCEDURE f(x) / ENDPROCEDURE |
| Modulo / Integer div | % // |
MOD DIV |
MOD DIV |
MOD DIV |
| String length | len(s) |
s.length |
LEN(s) |
LENGTH(s) |
| Upper / Lower | s.upper() |
s.upper |
UPPER(s) |
UCASE(s) |
| Substring | s[2:5] |
s.subString(2, 3) |
SUBSTRING(2, 5, s) |
MID(s, 3, 3) (1-indexed) |
| Random integer | random.randint(1,6) |
Random(1, 6) |
RANDOM_INT(1, 6) |
INT(RAND(6)) + 1 |
| Cast to int | int(x) |
int(x) |
STRING_TO_INT(x) |
INT(x) |
| File: open read | with open("f.txt") as f: |
f = open("f.txt") |
f ← OPENREAD("f.txt") |
OPENFILE "f.txt" FOR READ |
| File: open write | with open("f.txt","w") as f: |
f = open("f.txt") |
f ← OPENWRITE("f.txt") |
OPENFILE "f.txt" FOR WRITE |
| File: read line | line = f.readline() |
line = f.readLine() |
line ← f.READLINE() |
READFILE "f.txt", line |
| File: write line | f.write("text") |
f.writeLine("text") |
f.WRITELINE("text") |
WRITEFILE "f.txt", "text" |
| File: close | # auto (with block) |
f.close() |
f.CLOSE() |
CLOSEFILE "f.txt" |
CIE note: Same pseudocode standard for IGCSE (0478/0984) and A Level (9618). The attached guide is A Level but GCSE syntax is identical. CIE for-loops are 1-indexed by default and use NEXT i (not ENDFOR). WHILE loops require DO. Not-equal is <> (not ≠ or !=).