Writing readable code and from algorithms to programs

Code is read far more often than it is written. Clear code is easier to fix, improve and share.

Practise this lesson free (6 questions)

More tools

Making code readable

Comments (starting with #) explain what code does and why.
Meaningful identifiers such as total_price instead of tp or x.
Indentation shows the structure of loops, ifs and subprograms (and is required in Python).
White space and blank lines separate sections. A clear layout keeps related code together.

Structural components

Look for these in any program: constants and variables, initialisation (total = 0), assignment, sequence, selection (if), repetition (while, for), iteration over a data structure, data structures (lists), subprograms with parameters, and input/output.

From algorithm to program

Each flowchart or pseudocode part becomes a Python construct:
Process box → assignment. Decision diamond → if or a loop condition. Input/output box → input() or print(). Arrow back up to an earlier step → a loop.
This program adds up the positive numbers among 5 inputs:
total = 0
for count in range(5):
    num = int(input("Number: "))
    if num > 0:
        total = total + num
print(total)
Worked example

The program in step 3 is given the inputs 4, -2, 7, 0, 3. What is output?

  1. Only positive numbers are added: 4, 7 and 3.
  2. 4 + 7 + 3

Answer: 14

Key idea

Comments, meaningful identifiers, indentation and white space make code easy to maintain. Decision symbols become if statements or loop conditions; process boxes become assignments.

Key words
Indentation
Spaces at the start of lines showing which code belongs to a block. Python requires it.
Initialisation
Giving a variable its first value before it is used.
Assignment
Storing a value in a variable, such as total = 0.
Sequence
Instructions carried out one after another in order.
Selection
Choosing which code runs using a condition, such as if, elif and else.
Iteration
Repeating code, or visiting each item of a data structure in turn.

All GCSE and International GCSE Computer Science key terms and definitions →

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. Which line is a comment in Python?

    1. total = 0
    2. print("total")
    3. # work out the total
    4. total
    Show the answer

    Answer: # work out the total

    Comments start with #.

  2. Which is the most meaningful variable name for the number of lives a player has left?

    1. l
    2. x2
    3. lives_left
    4. n
    Show the answer

    Answer: lives_left

    Say what it holds.

Check you have got it

Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

What do exam command words like explain and evaluate mean? →

Related lessons