Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

One algorithm, three ways to write it

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

45 minutes

Same idea, three forms

You can show a friend the way to the station in three ways. You can draw a map. You can say the steps. You can use a phone app.

An algorithm is the same. We can draw it as a flowchart. A flowchart is a picture made of shapes and arrows. We can write the steps in words. Or we can write code.

Key words

WordWhat it meansExample
Written descriptionAn algorithm written as numbered steps in plain words.1 Ask for the age
Hierarchical markerA number that shows the order and what belongs to what.1, 2, 2.1, 2.2, 3
CodeInstructions in a programming language that a computer runs.print("Hi")
TranslateSay the same algorithm in another way.from a flowchart to code
FlowchartA picture of an algorithm made of shapes and arrows.start, check age, end
SelectionChoosing a path by asking a question.if age is under 16
IterationRepeating steps.while n is more than 0
LoopAnother name for iteration.repeat while n is more than 0

The cells students fill in are left blank in this preview.

A bus fare in words

MarkerStep
1Ask for the age.
2If the age is under 16:
2.1The fare is 1.
3Otherwise:
3.1The fare is 2.
4Show the fare.

The cells students fill in are left blank in this preview.

Read the steps

Have a go

Read the steps

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Written steps with markers

A written description uses numbers. The numbers show the order. A step with a number like 2.1 belongs to step 2.

This is the hierarchical marker idea: the bigger numbers are the main steps. The numbers with a dot are the smaller steps inside.

The same algorithm as Python code

Code: python
age = 12

if age < 16:
    fare = 1
else:
    fare = 2

print(fare)

# Change age to 30 and run it again.

More than two choices

data-callouts.tip.label

Use elif for a second question. It means "else if". Python checks if, then each elif, then else. It runs only the first one that is true.

Translate step by step

FlowchartWritten stepsPython
Input: age1 Ask for the ageage = int(input("Age? "))
Decision: age under 16?2 If the age is under 16if age < 16:
Process: fare is 12.1 The fare is 1 fare = 1
Other arrow (no)3 Otherwiseelse:
Output: fare4 Show the fareprint(fare)

The cells students fill in are left blank in this preview.

The lesson goes on

8 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.