Checking 30 survey sheets before lunch
An analyst must check 30 sheets. For each one: open it, count the blank answers, and if there are too many, put it in the red pile.
The job has an order, a choice and a repeat. Every algorithm (a set of clear steps) is built from just these three actions.
Key words
| Word | What it means | Example |
|---|---|---|
| Sequence | Steps done one after another in order | |
| Selection | A choice: do a step only if a condition is true | if blanks are many |
| Iteration | Doing steps again and again | |
| Condition | A test that is true or false | |
| Loop | Python code that repeats steps | |
| Flowchart | A picture of steps and choices joined by arrows |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can design an algorithm that uses sequence, selection and iteration.
Starter
Have a go
Starter
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Sequence: one step after another
Sequence means the steps run in the order you write them. The computer does step 1, then step 2, then step 3.
Order matters. "Open the sheet" must come before "count the blanks".
Try it: a sequence
print("1. Open the sheet")
print("2. Count the blank answers")
print("3. Record the result")
# Swap lines 2 and 3 and press Run. The order changes.
Selection: a choice
Selection means the algorithm chooses what to do. It asks a question. If the answer is yes it does one thing. If no, it does another.
In a flowchart, selection is a decision shape. In Python it is if and else.
Try it: a choice
blanks = 15
if blanks > 10:
print("Red pile")
else:
print("Green pile")
# Change blanks to 2 and press Run.
Check
Have a go
Check
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.