A map app plans first
A map app on your phone does not drive the car. It plans the route first. It knows each turn before you reach it.
A good developer plans the steps first too, before writing code. A plan is easier to change than finished code.
In the design task you draw the steps and say how they work.
Key words
| Word | What it means | Example |
|---|---|---|
| Design | A plan of how something will work, made before you build it. | a flowchart |
| Algorithm | A list of steps that solves a problem. | the steps to check a booking |
| Flowchart | A diagram of steps with arrows. | start, check, book |
| Pseudocode | Steps written in plain words that look like code. | IF hour < 9 THEN refuse |
| Decision | A question with a yes or no answer. Each answer goes to a different path. | Is the court free? |
| Edge value | A value right at the limit of what is allowed. | hour 9 or hour 20 |
| Symbol | A shape in a flowchart. Each shape has one meaning. | a diamond |
The cells students fill in are left blank in this preview.
Quick check: reading the flowchart
Have a go
Quick check: reading the flowchart
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Pseudocode: the same steps in words
Pseudocode is a plan written in plain words. It looks a bit like code but no computer runs it. Each line matches a part of the flowchart.
Pseudocode has no fixed rules. Keep it short and clear. Write every line in the same way.
Flowchart, pseudocode and Python
| Flowchart | Pseudocode | Python |
|---|---|---|
| Input: hour and court | INPUT hour, court | hour = int(input("Hour: ")) |
| Is the hour from 9 to 20? no | IF hour < 9 OR hour > 20 THEN output Closed | if hour < 9 or hour > 20: |
| Is the court 1 or 2? no | IF court is not 1 or 2 THEN output No such court | if court != 1 and court != 2: |
| Is it already booked? yes | IF (court, hour) is in taken THEN output Taken | if (court, hour) in taken: |
| Output: OK | OUTPUT OK | return "OK" |
The cells students fill in are left blank in this preview.
Try it: the flowchart as code
def check(hour, court, taken):
if hour < 9 or hour > 20:
return "Closed"
if court != 1 and court != 2:
return "No such court"
if (court, hour) in taken:
return "Taken"
return "OK"
taken = [(1, 10)]
print(check(10, 1, taken))
print(check(10, 2, taken))
print(check(8, 1, taken))
# < means less than. > means more than.
# != means is not equal to.
# Try hour 21. Try court 3.