A recipe that says "cook until done"
A recipe that says "cook until done" is no help if you have never cooked.
You send your design to a builder you have never met. You are away. They cannot ask you anything.
If a step says "check the booking", the builder must guess how. If a step says "if the hour is before 9, output Closed", the builder knows.
A good design can be built by a stranger.
Key words
| Word | What it means | Example |
|---|---|---|
| Sequence | Steps done one after another, in order. | ask, check, save |
| Selection | A choice. The path depends on a yes or no answer. | if the hour is 21, refuse |
| Iteration | Doing steps again and again. | for each hour from 9 to 20 |
| Loop | Code or a flowchart path that repeats steps. | while hour <= 20 (<= means 20 or less) |
| Flowchart | A diagram of steps with arrows. | start, check, book |
| Reusable component | A part you write once and use in many places. | price_for() |
| Sub-system | One big part of the whole solution. | prices, storage, screen |
| Naming convention | A rule for how names are written, used the same way everywhere. | small letters with _ between words, like book_court |
| Third party | A person outside your team, such as a builder who gets your design. | another developer |
| Audience | The people who read your design. | the manager, the builder |
The cells students fill in are left blank in this preview.
The three building blocks of every algorithm
| Construct | Flowchart shape | Hillside example | Python |
|---|---|---|---|
| Sequence | Boxes joined by arrows | Input the hour, then input the court, then save | Lines one after another |
| Selection | A diamond with yes and no | Is the hour from 9 to 20? | if ... else |
| Iteration | An arrow that goes back up | Do this for every hour from 9 to 20 | for or while |
The cells students fill in are left blank in this preview.
Which building block is it?
Have a go
Which building block is it?
5 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Try it: the same loop in Python
names = {10: "Sam", 12: "Aisha"}
hour = 9
while hour <= 20:
if hour in names:
print(hour, names[hour])
else:
print(hour, "free")
hour = hour + 1
# The arrow going back up is the while line.
# <= means "is less than or equal to".
# Change 20 to 12 and run it again.
Quick check: building blocks
Have a go
Quick check: building blocks
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.