Instructions anyone can follow
Write down how to make a cup of tea. Give it to a friend. Can they follow it exactly?
"Boil the water." Which pot? "Add milk." How much? Good instructions are clear, in order and complete.
Before you write code, you plan it in this way.
Key words
| Word | What it means |
|---|---|
| Flowchart | A diagram that shows the steps of a program as symbols joined by arrows. |
| BCS symbols | The standard flowchart shapes used in the UK. BCS is the Chartered Institute for IT. Its old name is the British Computer Society. |
| Pseudocode | Planning a program in plain words that look like code. No computer runs it. |
| Sequence | Steps that happen one after another. |
| Selection | A choice: the program takes one path or another. Also called branching. |
| Loop | Steps that repeat. |
| Iteration | Doing steps again and again. Also called a loop. |
| Control structure | Sequence, selection or iteration. They control the order of the steps. |
| Pre-defined code | Code that already exists, such as the built-in tools of a language, and that you reuse. |
The cells students fill in are left blank in this preview.
Flowchart symbols
| Symbol | Shape | Use it for | Example |
|---|---|---|---|
| Terminator | Rounded box | Start and end | Start |
| Process | Rectangle | A step that does something | Add 1 to total |
| Decision | Diamond | A yes or no question. Two exits. | Is age under 16? |
| Input or output | Parallelogram | Data in or out | Enter your age |
| Pre-defined process | Rectangle with double side lines | Code that already exists | Check the age is a number |
| Flow line | Arrow | Shows the order | From one step to the next |
The cells students fill in are left blank in this preview.
Three control structures
| Structure | In a flowchart | In pseudocode |
|---|---|---|
| Sequence | Steps in a line | SET price TO 5, then SET total TO price + 1 |
| Selection | A diamond with two exits | IF age < 16 THEN OUTPUT "child" ELSE OUTPUT "adult" END IF |
| Iteration | An arrow that goes back up | FOR i FROM 1 TO 3, OUTPUT i, END FOR |
The cells students fill in are left blank in this preview.
Try it: all three in Python
# Sequence
price = 4
count = 3
total = price * count
# Selection
if total > 10:
print("Big order:", total)
else:
print("Small order:", total)
# Iteration
for i in range(1, 4):
print("Ticket", i)
# Pre-defined code: len() and sum() already exist
print(sum([2, 4, 6]) / len([2, 4, 6]))
Writing pseudocode
Pseudocode looks like code but is for people. No computer runs it.
Use short capital words for the key ideas: INPUT, OUTPUT, SET, IF, THEN, ELSE, END IF, FOR, END FOR, WHILE. Indent (move to the right) the lines inside an IF or a loop. Write one step on each line. The sign < means "is less than".
The exact words can change from place to place. Pick one style and keep to it.
Read the pseudocode
Have a go
Read the pseudocode
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.