All 24 modules are open from the start — nothing here is
locked, and nothing costs anything. Sign in so your progress, titles and
credentials stay with you, on every device you use.
Free forever, with your Google account. No password, no payment.
A program is a list of instructions, written down, carried out in order. That
is the whole idea. This module covers the one instruction you will use more
than any other, how to leave notes for yourself, and what to do when Python
tells you it does not understand — which it will, and which is normal.
Ready?
1
A Program Is a List of Instructions
Think of a recipe. Each line is one instruction, and you carry them out
from the top down. A Python program works exactly like that: the
interpreter reads your file line by line and does what
each line says, in order, without skipping ahead.
The most useful instruction to start with is print(). It puts
something on the screen. Everything you want it to show goes inside the
brackets.
print("Hello, Dojo!")
Run that and you get one line of output: Hello, Dojo!. Three
parts are doing the work. print is the name of the job.
The brackets are what actually makes it happen — write
print on its own and nothing is printed, you have only said
the word. And the quotes mark where your text starts and
stops.
Everyday example, giving directions
"Turn left. Walk to the lights. Cross." Say those in a different order
and someone ends up somewhere else. Python is the same, and about as
literal as a person can be: it will not guess what you meant, spot that
you clearly wanted line 3 first, or quietly fix a typo. That sounds
harsh, and it is actually the good news — the same code does the same
thing every single time.
Does nothing
print
Names the function without calling it. No brackets, no output.
Prints a line
print("Go")
Brackets call it, quotes mark the text. One line of output: Go.
Quick check
A file contains three print() lines. In what order does the output appear?
2
Quotes Mark Text, Commas Separate Values
Text in Python is called a string, and it lives inside
quotes. Single or double both work — "Hello" and
'Hello' are the same thing — as long as you open and close
with the same one.
Numbers do not take quotes. 3 is a number Python can do
arithmetic with; "3" is a piece of text that happens to look
like one. That difference matters enormously later, and costs you nothing
to get right now.
print("Level", 3)
# Level 3
One print() can take several values separated by commas, and
it puts a single space between them. So the space in
Level 3 came from the comma, not from anything you typed.
Both of those defaults can be changed, and it is worth knowing now
because real output rarely wants a plain space.
sep= sets what goes between the values;
end= sets what goes after the last one, which is
normally the line break that makes the next print() start
below.
Open and close with the same character. Mixing them is an error.
Numbers go bare
3 is a number. "3" is text. Both print the same and behave differently.
Commas add a space
print("a", "b") gives a b, with the gap supplied for you.
One print, one line
Each print() ends its line, so the next one starts fresh below.
Quick check
What does print("Score:", 100) put on the screen?
3
Comments: Notes Python Ignores
Anything after a # on a line is a comment.
Python skips it entirely. Comments exist for people — most often for you,
three weeks from now, staring at your own code with no memory of writing
it.
# Prices are exclusive of tax — finance asked for it this way.
print("Total: 40")
print("Ready") # a comment can also sit after code
A comment is also the quickest way to switch a line off without
losing it. Put a # at the front and the line stops running,
but stays there if you want it back.
Write the why, not the what
# add 1 to score next to score = score + 1
tells the reader nothing the code did not already say. # one
point per completed module, agreed with design tells them something
the code cannot: the reason. A good comment explains a decision, a
constraint, or a surprise.
Quick check
Your program prints a line you do not want any more, but you might want it back next week. What is the quickest safe move?
4
Reading an Error Instead of Fearing It
You will break things constantly, and that is not a sign of anything. When
Python cannot do what you asked, it prints a traceback —
a short report that tells you what went wrong and where.
Traceback (most recent call last):
File "your_code.py", line 2, in <module>
NameError: name 'score' is not defined
Read it from the bottom up. The last line names the
problem: something called score was used before it existed.
The line above says where: line 2. Those two facts solve the large
majority of beginner errors on their own.
1
SyntaxError
Python could not understand the shape of the code, so nothing ran. Usually a missing bracket, quote or colon — and usually on the line above the one it names.
2
NameError
You used a name Python has never seen. A typo, or something you meant to create first.
3
TypeError
The right idea applied to the wrong kind of value, like adding a number to a piece of text.
Nothing here can break
The editor in the next tab runs real Python inside this browser tab. It
touches nothing on your computer and sends nothing to a server. An
infinite loop gets stopped after ten seconds; a crash costs you one
click. There is no way to do damage, so the only sensible strategy is
to try things and read what comes back.
The Run button is free. Use it far more often than feels necessary.
Quick check
A traceback ends with SyntaxError: '(' was never closed and points at line 8. Where is the mistake most likely to be?
0 of 9 completed
Real Python runs right here in your browser — nothing to install, nothing
sent to a server. The interpreter downloads once the first time you press
Run, then stays cached.
01
To do
print() is how a program talks to you. Whatever you put
between the brackets appears on the screen.
Text has to sit inside quotes so Python knows it is words and not
instructions. Both "double" and 'single' quotes
work, as long as you start and finish with the same one.
Your task: print exactly Hello, Dojo!
your_code.py
PythonCtrl↵ to run
Hint
One line is enough: print("Hello, Dojo!") — the quotes go inside the brackets, and the capital H and the exclamation mark both matter.
Output
02
To do
Python reads your file from top to bottom, one line at a time. Three
print() lines produce three lines of output, in the order
you wrote them.
Your task: print these three lines, in this order:
Ready Set Go
your_code.py
PythonCtrl↵ to run
Hint
You need three print() lines in total. Each one prints one word, and the order you write them in is the order they appear.
Output
03
To do
One print() can take several values, separated by commas.
Python prints them on one line with a space between each.
print("Level", 3) → Level 3
Notice that 3 has no quotes. It is a number, not text, and
print() is happy with either.
Your task: using a singleprint(),
produce exactly Module 1 completed. The 1 must
be a number, not text in quotes.
your_code.py
PythonCtrl↵ to run
Hint
print("Module", 1, "completed") — the commas do the spacing for you, so do not add spaces inside the quotes.
Output
04
To do
Quotes are how Python tells your words apart from its own
instructions. Write print(Ready) and Python does not
see the word "Ready" — it goes looking for something called
Ready, finds nothing, and stops with a
NameError.
Numbers are the exception. 3 needs no quotes, and it should
not have any: "3" is text that happens to look like a number,
and Python cannot do arithmetic with it later.
Your task: this deploy banner is broken. Run it first and
read the error, then fix it so it prints:
Build Version 2 Deployed
Leave the 2 as a number.
your_code.py
PythonCtrl↵ to run
Hint
Two of the three lines are missing their quotes. The middle line is already correct — copy the shape of it.
Output
05
To do
The space between comma-separated values, and the line break at the end,
are both just defaults. print() lets you change either one.
print("2026", "09", "02", sep="-") → 2026-09-02 print("Uploading...", end=" ") → no line break yet
sep= is what goes between the values.
end= is what goes after the last one — normally a
line break, which is why each print() starts a new line.
Set it to something else and the next print() carries on
where this one stopped.
Your task: produce exactly these two lines of output:
2026-09-02 Uploading... done
Build the date from three separate values with sep=, and
build the second line from twoprint() calls using
end=.
your_code.py
PythonCtrl↵ to run
Hint
print("2026", "09", "02", sep="-") for the date. Then print("Uploading...", end=" ") followed by print("done") — the end=" " replaces the line break with a space.
Output
06
To do
A line starting with # is a comment. Python
ignores it completely. Comments are notes for humans — including you, in
three weeks, wondering what you meant.
A comment is also the quickest way to switch a line off without deleting
it, which is exactly what the code below needs.
Your task: this program prints a line it should not.
Comment out the middle print() so only Open and
Closed appear, and add a comment of your own explaining why.
your_code.py
PythonCtrl↵ to run
Hint
Put a # at the very start of the line you want Python to ignore. Then add one more line anywhere that starts with # — that is your own note.
Output
07
To do
# print stuff tells the next reader nothing the code did not
already say. A comment is worth writing when it carries something the
code cannot: a reason, a constraint, a decision someone made.
The situation: finance is re-doing how tax is
calculated, so the tax line has to come off the receipt for now. It is
coming back next quarter, so nobody wants it deleted.
Your task: switch the tax line off with a
#, and replace # print stuff with a comment
that explains why it is off. Mention tax, and write a real sentence — the
person reading it in three months is the point.
The output should be:
Order 4471 Total: 48.00
your_code.py
PythonCtrl↵ to run
Hint
Put a # at the front of the Tax line. Then rewrite the first line as something like: # Tax line is off until finance ships the new rates — back next quarter.
Output
08
To do
A teammate sends you this and says it will not run. That is most of the
job. A SyntaxError means Python could not make sense of the
shape of the code, so nothing ran at all — and it usually points
at the line after the real mistake, because that is where it
finally gave up.
Your task: press Run, read the bottom line of the
traceback, fix one thing, and run again. Repeat until it works. Change as
little as you can — the output is supposed to be:
Deploy started Region: eu-west-1 Deploy finished
your_code.py
PythonCtrl↵ to run
Hint
Two separate faults. One line never closes its bracket. Another opens with a single quote and closes with a double, which is not a matching pair.
Output
09
To do
The three errors from the lesson, one per line. Python reports only the
first one it hits, so this is three runs, not one — fix, run, read the
next.
1
SyntaxError
Python could not read the code. Nothing ran.
2
NameError
A name was used that Python has never seen.
3
TypeError
The right idea, the wrong kind of value — like adding a number to text.
Your task: fix all three so the program prints:
Checks: 3 Passed Failures: 0
Keep 3 and 0 as numbers.
your_code.py
PythonCtrl↵ to run
Hint
Line 1 is missing the comma between the two values. Line 2 is missing its quotes. Line 3 tries to add a number to text — a comma does what the + was reaching for.
Output
Print the run report
To do
Every time the dojo's test suite runs, it prints a short report to the
console. Yours is the code that prints it.
Matching the text is not enough on its own. A report is printed with
different numbers every run, so the checks also look at how you
built it:
1
The numbers stay numbers
4471, 12 and 3 must be values in their own right, separated by commas — not characters typed inside a string.
2
The date is joined, not typed
Build it from "2026", "09" and "02" with sep="-" rather than writing the dashes yourself.
3
Date: and the date share a line
Two print() calls land on one line — that is what end= is for.
4
Leave a note
Add a comment saying why the numbers are not part of the text. Write it for the next person, not for the checker.
your_code.py
PythonCtrl↵ to run
Hint
Line 1: print("=== RUN", 4471, "===") — the commas supply both spaces. Line 2 is two calls: print("Date:", end=" ") then print("2026", "09", "02", sep="-"). Line 3: print("Checks:", 12, "passed,", 3, "failed"). The bottom border is 16 equals signs, the same width as the top line.