Basic

What is computational thinking?

Learn how to break a big problem into small, clear steps that a computer can follow.

What you will see

Doing: Boil water Doing: Add pasta Doing: Drain Doing: Mix sauce Finished 4 steps

About 2 min of reading

Try It

An algorithm is a finite list of clear, ordered steps a machine can follow. I turn a recipe into that list, spell out each number so nothing stays vague, then run a loop over the steps and watch it finish exactly once.

1

I write a recipe as five plain steps, then loop through them with a numbered index and print each one. The machine follows the same ordered list every run, so the output is a tidy numbered plan.

steps = ["Boil water", "Add pasta", "Wait 10 minutes", "Drain the water", "Add sauce"] for i, step in enumerate(steps, start=1): print(f"{i}. {step}")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
1. Boil water 2. Add pasta 3. Wait 10 minutes 4. Drain the water 5. Add sauce
enumerate(list, start=1) gives each item its position, so step numbers line up with the list instead of starting at 0.
2

A machine has no common sense, so vague words like 'a little' cannot run. I replace them with exact numbers and print the finished instructions, showing how precision turns a fuzzy recipe into a runnable plan.

salt_grams = 5 water_ml = 1000 print(f"Add {water_ml} mL of water") print(f"Add {salt_grams} grams of salt")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Add 1000 mL of water Add 5 grams of salt
Every number must be written down as a literal. 'Some salt' never runs; only '5 grams' does.
3

A real algorithm always finishes. I loop through the recipe steps, printing what I do, then print the finished total at the end to prove the ordered steps all ran exactly once.

steps = ["Boil water", "Add pasta", "Drain", "Mix sauce"] total = 0 for step in steps: print(f"Doing: {step}") total = total + 1 print(f"Finished {total} steps")

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Doing: Boil water Doing: Add pasta Doing: Drain Doing: Mix sauce Finished 4 steps
A loop that never ends is not an algorithm. Here each step runs once, so the total stays finite and the program stops.

Put it in order

Before you write anything, put these lines back in the right order. Click a line to move it up one step. This support step is easier than writing code from scratch, and it is here to make the last example stick.

Data Flow

A problem is decomposed into ordered steps, then executed one by one until the result is reached.
1 See the big problem -> break it into smaller steps
↓
2 Order the steps -> make a clear sequence
↓
3 Execute each step -> the machine follows the list
↓
4 Check the result -> did we reach the goal?
Why this works
The four pillars

Computational thinking rests on four habits:

  • **Decomposition*: split a big problem into smaller ones.
  • **Pattern recognition*: spot what repeats.
  • **Abstraction*: keep what matters, ignore the noise.
  • **Algorithm design*: write the ordered steps.

Big problem  ->  Break it down  ->  Order the steps  ->  Check them

If you can do those four things, you can solve almost any problem a computer can help with.

What an algorithm is

An algorithm is a finite list of steps that solves a problem. Every recipe, map, and instructions-for-assembly are algorithms. The key rules:

  1. Each step must be unambiguous.
  2. There are only a finite number of steps.
  3. It always finishes.

steps = ["boil water", "add pasta", "drain", "mix sauce"]
for step in steps:
    print(step)

That loop is an algorithm running.

Examples

Turning a recipe into steps

Breaking a recipe into steps

Cooking a meal is already a list of steps. Computational thinking just makes that list unambiguous.

1. Boil water
2. Add pasta
3. Wait 10 minutes
4. Drain the water
5. Add sauce

Each step is atomic, you can't do it wrong. That is the whole idea: describe what to do, not how it feels.

Why precision matters

A computer follows exactly what you say

Computers do exactly what you tell them, not what you meant. A vague instruction like "cook it well" cannot be run.

Bad:  "add some salt"
Good: "add 5 grams of salt"

Why it works: a machine has no common sense, so every detail must be written down.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

Next Lesson
Reading & drawing flowcharts
Reading & drawing flowcharts →