Florence's Computing · Programming · Lesson 3
def

Telling a machine
exactly what to do.

A program is a recipe a computer follows, step by step, without ever guessing. Python is one of the friendliest languages for writing those recipes — clear enough to read almost like English.
For Florence,
writing her first lines.
Florence's Computing · Lesson 3
What it really is

A program is a recipe.

A computer is fast, tireless and exact — and completely without judgement. It does precisely what it is told, in the order it is told, and not one thing more. A program is simply the list of instructions you give it: a recipe. Cook the steps in order, and you get the dish. Swap two steps, or leave one out, and you get something else — the computer will not quietly fix it for you, because it doesn't know what you meant. It only knows what you wrote.

To write instructions a computer can follow, you use a programming language. There are many, but the one you'll learn here is called Python — chosen because its lines read almost like plain English, which makes it gentle to start with. Throughout this lesson, when you meet a piece of code, do one thing first: read it like a recipe, slowly, one line at a time, asking "what does this step do?" That habit alone will carry you a long way.

The golden rule

A computer does exactly what you write, in order, and nothing more. It never guesses your meaning. Most "bugs" — mistakes in a program — are simply the gap between what you meant and what you actually told it to do.

A detail worth knowing
30–45 seconds · MF 1
Cool fact

Python is one of the most widely used languages on Earth. It runs scientific research, films' special effects, and parts of websites you use every day. It was even used to help process the first-ever photograph of a black hole, in 2019 — the same language a beginner writes their first line in.

Florence's Computing · Lesson 3
Watch

What programming actually is.

Before you read any code, watch this short film once. Listen for one idea you've just met — that a program is a precise list of steps the computer follows exactly — and notice how a small change to the steps changes what comes out.

Code.org — “What is programming?”.YouTube
Florence's Computing · Lesson 3
Your first line

print( ) — making the computer say something.

The first thing most people ever write in Python makes the computer show a message on the screen. The instruction for that is print. You give it some words to show, in round brackets, with quote marks around them. Read it like a recipe: print — followed by what to print, in brackets.

print("Hello, Florence!")
What it does: shows the words inside the quote marks on the screen. The quote marks tell Python "these are letters to show, not an instruction" — and they don't appear in the result.
It shows: Hello, Florence!

Those words inside the quote marks have a name. A piece of text in a program is called a string, because it is a row of characters strung together. You can print as many lines as you like — each print shows its own line, in order, from top to bottom:

print("Good morning.")
print("It is Tuesday.")
What it does: runs the two steps in order — first line, then second. The computer never jumps ahead.
It shows:
Good morning.
It is Tuesday.
Read it like a recipe

Whenever you meet a line of code, say it out loud as a step: "print the words Hello, Florence". Naming what each step does, in order, is exactly how a programmer reads a program — and exactly how the computer runs it.

Florence's Computing · Lesson 3
Boxes with names

Variables — giving a value a name.

Often you want the computer to remember something — a name, a score, a price — so you can use it later. For that you use a variable: a named box you put a value into. You make one with an = sign — but careful, in programming the = doesn't mean "equals", it means "put this value into this box".

name = "Florence"
age = 14
print(name)
What it does: puts the string "Florence" into a box called name, and the number 14 into a box called age. Then it prints what's in the name box. Notice there are no quote marks around name on the last line — we want what's inside the box, not the word "name".
It shows: Florence

The value in a box can change as the program runs — that's why it's called a variable, from "vary". Put a new value in, and the old one is gone:

score = 0
score = score + 10
print(score)
What it does: starts score at 0, then puts "the old score plus 10" back into the same box — so it becomes 10 — and prints it.
It shows: 10
A detail worth knowing
30–45 seconds · MF 1
Cool fact

A variable name can be almost anything you like, but good programmers choose names that explain themselves — like player_score rather than x. Code is read far more often than it is written, so a clear name is a gift to whoever reads it next — which is usually your future self.

Florence's Computing · Lesson 3
Talking back

input( ) — letting the person answer.

A program gets far more interesting when it can ask the person a question and use their answer. The instruction for that is input. It shows a prompt, waits for the person to type something and press Enter, and hands back whatever they typed — so you usually put the answer straight into a variable.

name = input("What is your name? ")
print("Hello, " + name)
What it does: shows the question, waits for an answer, puts what's typed into the name box, then prints "Hello, " joined to the answer. The + between two strings glues them together.
If they type Florence, it shows: Hello, Florence

Now an important catch. There are different kinds of value. Text is a string (often shortened to str); a whole number is an int (short for "integer", a whole number). Here is the catch: whatever the person types into input always comes back as a string, even if they typed digits. So "14" the string is not the same as 14 the number — you can't do sums with it until you convert it, using int( ):

age = input("How old are you? ")
age = int(age)
print("Next year you will be", age + 1)
What it does: takes the typed answer (a string), turns it into a whole number with int(), and then can add 1 to it. Without that middle line, "14" + 1 would be an error — you can't add a number to a piece of text.
If they type 14, it shows: Next year you will be 15
String or int? — a quick test

If it has quote marks, it's a string (text). If it's a bare whole number with no quotes, it's an int. You can do arithmetic with ints. You can join strings with +. Mixing them up is one of the most common beginner errors — and now you know to watch for it.

Florence's Computing · Lesson 3
Making a choice

if — doing something only when it's true.

So far the recipe runs straight through, every line, every time. But real programs make decisions. The if statement lets a program choose: if some condition is true, do these steps; otherwise (else), do those. Read it like a recipe with a fork in it.

age = 14
if age >= 13:
    print("You are a teenager.")
else:
    print("Not a teenager yet.")
What it does: checks whether age is 13 or more. If it is, it prints the first line; if not, it prints the second. Only one of the two ever runs.
With age = 14, it shows: You are a teenager.

Two things to notice. The condition ends with a colon (:), and the lines that belong to it are pushed in from the left — that gap is called indentation, and in Python it isn't just tidy, it's how the computer knows which steps belong to the if. And the sign >= means "greater than or equal to"; a single = would be wrong here, because that means "put into a box". To compare two values for being equal, you use a double ==.

Cool fact

Most programming languages mark out blocks of code with curly brackets { }. Python is unusual: it uses the indentation — the spaces at the start of a line — instead. That choice was deliberate, to force code to look as tidy as it behaves. It divides programmers to this day.

Florence's Computing · Lesson 3
Doing it again

for — repeating a step without writing it out.

Computers are wonderful at doing the same thing over and over without getting bored. Rather than copy a line five times, you write it once inside a for loop and tell Python how many times to run it. Read it like a recipe step that says "repeat this".

for i in range(3):
    print("Hip hip!")
What it does: runs the indented line 3 times. range(3) counts 0, 1, 2 — that's three turns — and i is the box holding the turn number, in case you want it.
It shows:
Hip hip!
Hip hip!
Hip hip!

Because i holds the turn number each time round, you can even use it inside the loop:

for i in range(3):
    print("Count:", i)
What it does: prints the turn number each time. Since range(3) counts 0, 1, 2, that's what gets printed — programmers usually start counting at 0.
It shows:
Count: 0
Count: 1
Count: 2
The two great labour-savers

Almost all programs are built from two ideas you've now met: if (choose between paths) and for (repeat a step). With printing, variables, input, those two — and patience — you can already write a surprising amount.

Florence's Computing · Lesson 3
Watch

Loops, brought to life.

You've just met the for loop on paper. This short film shows why repeating a step is so powerful — and how a loop saves a programmer from writing the same line a thousand times. Watch for the moment a single instruction stands in for many.

Code.org — “Repeat loops”.YouTube
Try it

Run the recipe, one line at a time.

Here is a tiny program. Press Run next line to be the computer — watch the highlighted line run, see the variable boxes fill, and the screen fill in. This is exactly how a program thinks: one line, in order, every time.

Variables (the boxes)

none yet

Screen (what print shows)

nothing yet
Press “Run next line” to begin. Nothing has run yet.

The loop runs its inside line three times before moving on — watch the score climb 0, 10, 20, 30. This is what "reading code like a recipe" feels like from the computer's side.

Florence's Computing · Lesson 3
Question 1 · circle the correct answer

What a program is.

Which sentence describes a program best?
Question 2 · type your answer

What does this code print?

Read it like a recipe, one line at a time. What appears on the screen?
x = 5
x = x + 3
print(x)
it prints
The line x = x + 3 means "put the old x plus 3 back into x".
Question 3 · circle the correct answer

What input gives back.

A person types 14 in answer to an input(). What kind of value does Python hand back?
Florence's Computing · Lesson 3
Question 4 · type your answer

What does this loop print?

Read it like a recipe. How many lines does this print on the screen?
for i in range(4):
    print("Hello")
number of lines:
range(4) counts 0, 1, 2, 3 — count how many that is.
Question 5 · circle the correct answer

What if chooses.

Read this carefully:
age = 9
if age >= 13:
    print("Teenager")
else:
    print("Not yet")
What does it print?
Question 6 · circle the correct answer

The two equals signs.

In Python, what is the difference between = and ==?
Question 7 · circle the correct answer

Why int() is needed.

A program reads a number from input() and tries to add 1 to it, but it gives an error. What is the usual fix?
Florence's Computing · Lesson 3
Question 8 · in your own words

Explain what a variable is, to someone new.

Imagine explaining it to a friend who has never written code. Use a picture if it helps — a box, a label, a shelf. Try to get across two things: that a variable holds a value you give it, and that the value can change as the program runs. Three or four sentences is plenty. Try to use, in your own way, the words variable, value and = (and what it really means).

0 words
reading what you wrote…

A few thoughts on your explanation, Florence

strong The "labelled box" picture is exactly the right one, and you reached for it on your own — that's the image real programmers carry in their heads. You also caught the part most people miss: that the value can change while the program runs, which is the whole reason it's called a variable.

try this One sentence calls the = sign "equals", out of habit. Worth a small fix: in code it isn't "equals", it's "put this value into the box". Naming that difference shows you've understood something a lot of beginners trip over.

to add A tiny example would seal it — one line like score = 0, then a sentence on what that line actually does. Showing the idea in action turns an explanation into a demonstration.

Watch together

Films and series on code and the people who write it.

Sit down with Dad for any of these. They show where code came from and what it can do. Heavier titles flagged for a chat first.

Documentary · BBC · 2015 · PG
Calculating Ada: The Countess of Computing
Ada Lovelace wrote what many call the first program, in the 1840s, for a machine that was never even built. The very idea of a list of instructions starts with her.
Documentary · 2015 · U
CODE: Debugging the Gender Gap
A warm look at who writes software, and at the many women in the story of computing who were quietly left out of it. Encouraging rather than heavy.
Drama · 2016 · PG
Hidden Figures
The mathematicians whose calculations sent NASA into space — and who learned to program the first room-sized computers when the work changed under them.
Documentary · 2001 · PG
The Secret Life of the Machine — Tim Hunkin
Hand-drawn, gentle, and brilliant on how everyday machines really work — a calm companion to the idea that everything a computer does is, underneath, a set of simple steps.
Drama · 2014 · 12A
The Imitation Game
Alan Turing, who first set out what a machine following instructions could and couldn't do. The thinking behind every program ever written. Heavier in places — chat afterwards.
Florence's Computing · Lesson 3
Glossary

The words from today.

Program
A list of instructions a computer follows in order, exactly as written — like a recipe.
print( )
An instruction that shows what's inside the brackets on the screen.
Variable
A named box that stores a value. You put a value in with =, and the value can change as the program runs.
String / int
A string is text (in quote marks); an int is a whole number. input() always gives back a string.
if / else
A way to make a choice: do one thing if a condition is true, otherwise do another.
for loop
A way to repeat a step a set number of times without writing it out again and again.
Watch

Worth watching.

Two short films to watch alongside today's lesson — each shows you something the words and pictures can't.

A gentle sense of what programming is and why it's a creative, useful skill.Khan Academy · YouTube
Watch Python store and change information using variables.Khan Academy · YouTube
End of lesson three

You've written your first lines.

You learned that a program is a recipe a computer follows exactly, in order. You met print to show things, variables to remember them, input to ask the person, and the catch that input always comes back as a string. You saw if make a choice and for repeat a step. That's the heart of programming — everything else builds on these. Florence, this is computing.

F.M. · Computing · Programming · Lesson 3
Cool fact

The first "bug" in a computer was a real insect. In 1947, engineers found a moth trapped in a relay of an early machine, taped it into the logbook, and wrote "first actual case of bug being found". The word "bug" for a fault had been used before — but that moth is why we still say a program has bugs.

Code · All Python examples in this lesson were written for it, and are short enough to type out and try. Use them freely.
Videos are embedded from Code.org's official YouTube channel.
Film recommendations are factual reference only — see each title's own copyright owner.