Product Dojo is a members' platform. Sign in to open the lessons, clear
stages, and earn the certificate for each one. Your rank and credentials
stay with your account across every device you use.
Free to join, through GitHub, Google or LinkedIn. No password to set.
Not unlocked yet
Stages open in order. Clear the one before this to come back here.
A program is a list of instructions, written down, carried out in order. That
is the whole idea. This stage 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?
Step-by-step lessons
From Nothing to a Running Program
Four short lessons: what a program actually is, how to make one speak, how to leave notes in it, and how to read the message you get when it breaks.
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.
Matching quotes
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 cleared stage, 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?
Type it yourself
Code Lab
Four short exercises. Write the code, press Run, and the checks tell you straight away whether it did what was asked. Getting it wrong costs nothing — that is what the Run button is for.
0 of 4 cleared
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
Say something
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
Three lines, three prints
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
Silence a line
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
04
More than one thing at a time
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 Stage 1 cleared. The 1 must be a
number, not text in quotes.
your_code.py
PythonCtrl↵ to run
Hint
print("Stage", 1, "cleared") — the commas do the spacing for you, so do not add spaces inside the quotes.
Output
Boss round
Assignment: Your Arcade Card
One graded task. Pass every check and the stage is cleared and the title is yours — one more stage towards the Python Practitioner certificate.
This one is graded. You can see 2
of the checks up front, and 4
stay hidden until you run. The hidden ones test the same job from angles
you have not been shown, so code that genuinely solves the problem clears
this and code shaped around the visible examples does not.
Pass them all and the stage is yours.
Print your arcade card
To do
Every player who walks into the dojo gets a card pinned to the wall. Write
the program that prints one.
Your task: print exactly these five lines, in this order:
Every character counts: the equals signs, the capital letters, and the
single space after each colon. Both border lines are 19 characters wide —
copy them exactly as shown.
The 1 on the Stage line must be a number rather than text, so
you will need a comma inside that print().
your_code.py
PythonCtrl↵ to run
Hint
Five print() lines. For the Stage line, print("Stage:", 1) gives you "Stage: 1" — the comma adds the space, so do not add one yourself.
Output
Lock it in
Guess the Term
Read the clues and name the concept. The fewer clues you need, the more points you score.
Round 1Score 0
Keep it handy
Hello, Python Quick Reference
The whole stage on one screen.
Printing
print("hi")
One line of output: hi
print("a", 1)
Commas separate values and add a space: a 1
print()
Nothing inside prints a blank line.
Values
"
Strings
Text in matching quotes: "hi" or 'hi'
7
Numbers
No quotes: 3, 3.5, -2
#
Comments
Everything after # is ignored by Python.
Common Errors
SyntaxError
Missing bracket, quote or colon. Nothing ran.
NameError
Used a name that does not exist yet. Often a typo.