Pseudocode and Python solve the same problem in different notations, and the syllabus for your exam year decides which one a question expects. Do not rely on a video, a friend’s notes or a website written for another year. Read the current syllabus on the Cambridge page for your code.
This page shows how to translate between the two, which differences cause wrong answers, and what to check. The safe Python reasoning sandbox lets you run small original exercises and watch the output.
What is the real difference?
Pseudocode is a plan written for people. It has no fixed grammar on your computer, so nothing “errors” if you miss a colon. Python is a language a computer executes, so a missing colon or wrong indent stops the program.
Because pseudocode is for readers, marks usually go to clear logic: the right loop, the right condition, the right variable updates. Python in practical work is judged by whether it runs and gives the right result. Check your syllabus for how each is assessed in your year.
How do I translate a loop step by step?
- Write the plain-English steps first: start a total at zero, add each number from 1 to 5, output the total.
- Write the pseudocode using the layout your syllabus guide shows.
- Translate line by line into Python, checking the loop bounds and the start values.
- Trace both by hand with the same input and compare.
Worked example
Task: add the whole numbers from 1 to 5 and output the total.
Pseudocode:
total ← 0
FOR i ← 1 TO 5
total ← total + i
NEXT i
OUTPUT total
Python:
total = 0
for i in range(1, 6):
total = total + i
print(total)
Trace: i takes the values 1, 2, 3, 4, 5, so total becomes 1, 3, 6, 10, 15. Both versions output 15.
Notice the bound. In the pseudocode, FOR i ← 1 TO 5 includes 5. In Python, range(1, 6) stops before 6, so 5 is included only because the end value is 6.
The mistake to watch for
A student copies the pseudocode bound straight across and writes range(1, 5).
That loop gives i = 1, 2, 3, 4, so the total is 1 + 2 + 3 + 4 = 10, not 15. The program runs without any error message, so it feels correct. The answer is wrong by exactly the missing last value.
The fix is to trace by hand with the smallest case. Ask “is my last value used?” before you run anything.
Where else do the two notations differ?
| Idea | Watch for |
|---|---|
| Position in a list or array | Some pseudocode guides start at 1, Python lists start at 0 |
| Whole-number division | Pseudocode often uses DIV and MOD, Python uses // and % |
| Assignment and comparison | Pseudocode may use ← and =, Python uses = and == |
| Block endings | Pseudocode uses words such as NEXT or ENDIF, Python uses indentation |
Check your own pseudocode guide for the exact keywords it uses.
Self-check
- What is the Python loop for “add the numbers from 2 to 6”? What is the total?
Show answer
`for i in range(2, 7):` gives 2, 3, 4, 5, 6. The total is 2 + 3 + 4 + 5 + 6 = 20.- The pseudocode is
FOR i ← 3 TO 6. How many times does the loop body run?
Show answer
i takes 3, 4, 5 and 6, so the body runs 4 times.- What do 17 DIV 5 and 17 MOD 5 give?
Show answer
17 DIV 5 = 3 (the whole-number quotient) and 17 MOD 5 = 2 (the remainder), because 3 × 5 + 2 = 17. In Python these are `17 // 5` and `17 % 5`.When might one-to-one tuition be worth considering?
Self-study is usually enough when you only need to learn a few notation differences. A teacher is worth considering when your programs run but keep giving wrong outputs, or when you lose marks on trace tables and pseudocode even though you can code.
A teacher can work on your own attempts, find the repeated habit, and build a short routine. You can read how we teach this subject on the Computer Science tuition page, see the Computer Science learning guide, or try a boundary test before editing code.