Module 1
Computational thinking (Python & Turtle)
Quick-reference revision notes for parents.
1.1 Decomposition
Decomposition = breaking a big problem into smaller, more manageable parts.
- Each smaller part can be solved on its own.
- Easier to share work, spot bugs and reuse pieces later.
Decomposed: 1) get bread, 2) butter it, 3) add filling, 4) close, 5) cut. Each step is small enough to do without thinking.
1.2 Abstraction
Abstraction = hiding the details that don't matter and keeping only what does.
- A map is an abstraction of the real world — only roads, places and key features.
- In code: a function name like
draw_square()abstracts away the 4 forward + 4 turn instructions inside.
1.3 Pattern recognition
Spot the parts of a problem that repeat or look similar. If you can find a pattern, a loop or a function will save lots of typing.
Without a loop:
import turtle t = turtle.Turtle() t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90) t.forward(100) t.right(90)
With a loop (pattern recognised):
for i in range(4):
t.forward(100)
t.right(90)
1.4 Pattern recognition with subroutines
A subroutine (also called a function) is a named block of code you can call whenever you need it.
def draw_square(size):
for i in range(4):
t.forward(size)
t.right(90)
draw_square(50)
draw_square(100)
draw_square(150)
defdefines the subroutine.sizeis a parameter — a value the subroutine receives when it's called.- You can call the same subroutine many times with different values.
1.5 Algorithms
An algorithm is a step-by-step set of instructions to solve a problem. They can be written as:
- Pseudocode — plain English with code-like structure.
- Flow chart — boxes and arrows.
- Code — actual programming language.
Flow chart shapes
INPUT age
IF age >= 18 THEN
OUTPUT "You can vote"
ELSE
OUTPUT "Too young"
END IF
1.6 Challenges
Putting it all together: shape challenges (squares, triangles, polygons) and maze challenges (navigate the turtle through a path). Use:
- Decomposition to break the maze into segments.
- Pattern recognition to spot repeated moves.
- Subroutines to keep code tidy.
Quick reference
- Decomposition — break problem into smaller parts
- Abstraction — hide unimportant detail
- Pattern recognition — find what repeats; use loops/functions
- Subroutine:
def name(param): - Loops:
for i in range(n): - Flow chart: rounded ends, parallelogram I/O, rectangle process, diamond decision