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.
Making code readable
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
From algorithm to program
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)
The program in step 3 is given the inputs 4, -2, 7, 0, 3. What is output?
- Only positive numbers are added: 4, 7 and 3.
- 4 + 7 + 3
Answer: 14
Comments, meaningful identifiers, indentation and white space make code easy to maintain. Decision symbols become if statements or loop conditions; process boxes become assignments.
- 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 →
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
Which line is a comment in Python?
- total = 0
- print("total")
- # work out the total
- total
Show the answer
Answer: # work out the total
Comments start with #.
Which is the most meaningful variable name for the number of lives a player has left?
- l
- x2
- lives_left
- 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.
- Pearson Edexcel GCSE Computer Science (1CP2) specification, topic 6.1.2, 6.1.3, 6.1.4, 6.2.1
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 1.1.6, 2.1.2, 2.2.1
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? →