Source: https://mokxi.com/teachers/plans/computational-thinking
Updated: 2026-11-19

Lesson plan

# Thinking like a programmer lesson plan

The habits behind the code, right after Python from zero: break problems down, spot patterns, read flowcharts, plan in pseudocode, trace by hand and debug, then build a sorting robot that shows its work in lights.

4 chapters, 7 lessons, about 5 hours, on the Raspberry Pi 4 Model B. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Break a problem into parts and find what repeats.
- Flowcharts and pseudocode: the program drawn and written in words first.
- Be the computer with a trace table, then debug one bug at a time.
- Every habit in one build: a sorting robot on the traffic lights.

### Materials for the whole unit

- Half breadboard
- LED x 2
- Pushbutton
- Raspberry Pi 4 Model B
- Resistor x 2
- Traffic light module

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 20 min

## See the shape

Break a problem into parts and find what repeats.

Lesson | Time | What students do

Break it down Decomposition: take a launch that is one long list of instructions, split it into named parts, give the parts inputs so one piece does many jobs, let a part answer GO or NO GO, and light the answer on the Pi. | 40 min

- Run it: one long list
- Name the parts
- Parts that take inputs
- A part that answers
- GO lights

Patterns and loops Spot what repeats and what changes: turn hand-written lines into a loop, describe a rocket shape with a rule, find the pattern that adds 1 to 100 without adding, and store a beacon's blink pattern as data. | 40 min

- Run it: spot the pattern
- Let the loop do it
- A rule for a shape
- Patterns in numbers
- A pattern as data

### Materials

- Half breadboard
- LED x 2
- Raspberry Pi 4 Model B
- Resistor x 2

### Check for understanding

Each student finishes "Patterns and loops" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A pattern as data".

Chapter 2. About 1 h 30 min

## Plan before code

Flowcharts and pseudocode: the program drawn and written in words first.

Lesson | Time | What students do

Flowcharts to code Read a flowchart and write the code it draws: boxes in a row become lines in order, a diamond becomes an if, an arrow back becomes a loop, and a wait for a person becomes a button. On a real traffic light module. | 40 min

- Run it: boxes in a row
- A diamond is an if
- An arrow back is a loop
- Waiting for a person
- Draw your own

Pseudocode first Plan in plain words before you write Python: turn pseudocode into code line by line to find the hottest of a day's hull temperatures, then the average and the hot hours, check your work against Python's built-ins, and raise an alarm. | 50 min

- Run it: a plan in plain words
- Line by line
- Plan the average
- Which hours?
- Check against the built-ins
- Raise the alarm

### Materials

- Half breadboard
- LED x 2
- Pushbutton
- Raspberry Pi 4 Model B
- Resistor x 2
- Traffic light module

### Check for understanding

Each student finishes "Pseudocode first" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Raise the alarm".

Chapter 3. About 1 h 20 min

## Check the work

Be the computer with a trace table, then debug one bug at a time.

Lesson | Time | What students do

Tracing by hand Be the computer: fill in a trace table for a loop before running it, print the trace to check yourself, trace a while loop to its last turn, find a swap bug on paper, and follow values through nested function calls. | 40 min

- Run it: predict first
- Print the trace
- Trace a while loop
- A bug found on paper
- Trace through calls

Debug a recipe Debug like a programmer, one bug at a time: predict what a recipe program should print, compare it with what it does, and fix a scaling formula upside down, a loop that skips the last step, two steps in the wrong order, and an egg count that rounds the wrong way. | 40 min

- Run it: predict, then compare
- Bug 1: upside down
- Bug 2: the missing step
- Bug 3: wrong order
- Bug 4: half an egg

### Materials

- Half breadboard
- LED x 2
- Raspberry Pi 4 Model B
- Resistor x 2

### Check for understanding

Each student finishes "Debug a recipe" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Bug 4: half an egg".

Chapter 4. About 50 min

## Project

Every habit in one build: a sorting robot on the traffic lights.

Lesson | Time | What students do

Project: a sorting robot on LEDs The project: a robot that sorts cargo crates by weight. Draw the crates as bars, do one pass of neighbor swaps, repeat it into a full bubble sort, stop early when nothing moves, show every compare and swap on the traffic lights, and count the cost of the worst case. | 50 min

- Run it: the crates
- One pass
- Repeat the pattern
- Work smarter
- The robot in lights
- The worst case

### Materials

- Pushbutton
- Raspberry Pi 4 Model B
- Traffic light module

### Check for understanding

Each student finishes "Project: a sorting robot on LEDs" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The worst case".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
