Computer Science · Programming and pseudocode

I wrote working Python and got half marks. Why?

AS and A Level 2 min read Worked answer

Because the paper asked for pseudocode and marks the structure, not whether the code would run. A correct Python answer can miss several structural marks while producing exactly the right output.

Where the marks actually sit

A typical algorithm question worth six marks distributes them roughly like this:

  1. Declaring variables with sensible names and types
  2. Correct input or initialisation
  3. The right loop construct, correctly bounded
  4. The condition inside the loop
  5. Updating the accumulator or result
  6. Output, and handling the edge case

Notice that only two or three of those are what a programmer would call "the logic". The rest is bookkeeping that Python either does invisibly or does not require at all.

The same algorithm, twice

Find the largest of 10 numbers entered by the user.

Python, which runs:

nums = []
for i in range(10):
    nums.append(int(input()))
print(max(nums))

That is correct, idiomatic, and would score poorly. max() does the assessed work, so the marks for initialising a maximum, comparing, and updating have nowhere to land.

Pseudocode, which scores:

DECLARE Numbers : ARRAY[1:10] OF INTEGER
DECLARE Index, Largest : INTEGER

FOR Index <- 1 TO 10
    INPUT Numbers[Index]
NEXT Index

Largest <- Numbers[1]

FOR Index <- 2 TO 10
    IF Numbers[Index] > Largest THEN
        Largest <- Numbers[Index]
    ENDIF
NEXT Index

OUTPUT Largest

Longer, and every extra line is a mark: the declarations, the initialisation of Largest to the first element rather than zero, the comparison, the update, the ENDIF and NEXT.

The specific habits that cost marks

Using a library function that does the assessed work. max(), sort(), sum(), in. If a built-in performs the exact task the question set, you have answered a different question.

Initialising a maximum to zero. It looks harmless and fails on all-negative data. Initialise to the first element. Examiners test this with negative inputs.

Missing block terminators. ENDIF, ENDWHILE, NEXT, ENDPROCEDURE. Python uses indentation, so the habit never forms, and each omission is a structure mark gone.

No declarations. Python does not need them. The mark scheme does.

Paper 4 is the opposite problem

The practical paper flips this. There you write real code in Java, VB.NET or Python, and the marks include evidence of testing: screenshots, test data chosen to exercise the edge cases, and the actual outputs.

Students who have spent months producing tidy code submit a perfect program with no test evidence and lose a substantial block of marks. The code was never the whole task.

How to fix it before the exam

Get the Cambridge pseudocode guide. It is short, it is published alongside the specification, and most students have never opened it.

Then rewrite five of your own Python solutions as pseudocode, by hand, on paper. The first one will feel absurdly verbose. That verbosity is the mark scheme, and after five it stops feeling like translation and starts feeling like the language you answer in.

Working from a past paper? Mark your attempt against the published mark scheme before reading an answer like this one. Finding out where you lost the marks is worth more than seeing a correct solution, because the correct solution rarely tells you what you did instead.

Related questions

Ordered by how close they are to this one: same topic first, then the same subject.