🐍 Python for beginners · session 1 of 57 · 60 minutes
Hello, Python: print, text and comments
Write and run your first programs. One idea at a time: learn it, see it run, practise it until it is easy, then move on. By the end you can print anything, do sums, draw with symbols and fix errors.
A complete lesson · 60 minutes
Teach it, see it, practise it, all on this page.
Open this page with your learner and work down it, or press Teach this lesson to go through it one step at a time on a big screen. Every section has something to do.
- Warm-up4 min
- Programs and print9 min
- Text and numbers9 min
- Comments and repeating8 min
- Fixing errors6 min
- Name badge8 min
- Shop receipt7 min
- Times-table strip5 min
- Quiz3 min
- Set the project1 min
By the end you can
- Explain what a program is and that Python runs it from top to bottom
- Use print() to show text and numbers
- Tell text (in quotes) apart from numbers and sums
- Draw with repeated strings and label code with comments
- Read an error message and fix the line
Before you start
- Can type on a keyboard
- No coding needed
Have ready
- A computer with this page open (nothing to install)
- A notebook for new words
Beginner · ages 10 and up
Warm-up · think first
You have a robot that does exactly what you say, in order, and nothing else. Write the steps for it to make a glass of lemonade. What goes wrong if you swap two steps or leave one out?
Show the answer
A program is a list of exact instructions that runs in order. If a step is missing ("open the tap") or two are swapped ("stir" before "add sugar"), the robot still follows them exactly, so the result is wrong. Computers are the same: they do what we write, not what we mean.
Teacher tip: Let the learner read their steps aloud while you act as the robot and follow them literally. Then say: today we give instructions to Python.
Part 1 of 4 · learn, see, practise
What is a program?
A program is a list of instructions for a computer. Python reads it from the top line to the bottom line, one line at a time.
print() shows whatever is inside its brackets. Text must go inside quotation marks, like "Hello": the quotes tell Python this is text to show, not an instruction.
Output
Hello, world! I am learning Python.
Memory boxes
Press Run. Line 1 runs, then line 2, so you see two lines in the same order. Swap the lines and run again.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
1.1 Print exactly: Hello, world!
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("Hello, world!")1.2 Print three lines: your name, your class and your school.
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("Asha")
print("Class 5")
print("Green Valley School")1.3 Print this poem exactly, on two lines:
Roses are red
Python is fun
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("Roses are red")
print("Python is fun")1.4 Print a triangle of stars exactly like this, one print per line:
*
**
***
****
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("*")
print("**")
print("***")
print("****")Part 2 of 4 · learn, see, practise
Text and numbers
Text inside quotes is a string. Numbers need no quotes, and Python can do maths with them: + adds, - subtracts, * multiplies, / divides.
print(7 + 5) shows 12, but print("7 + 5") shows the text 7 + 5, because it is inside quotes.
Commas let you print several things on one line; Python puts a space between them.
Output
12 7 + 5 My age is 11 Minutes in a day: 1440
Memory boxes
Lines 1 and 2 differ only by the quotes. Line 4 mixes text and a calculation.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
2.1 Make Python work out 25 + 17 and print the answer.
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print(25 + 17)2.2 Print the sum as text on line 1 and its answer on line 2:
7 + 5
12
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("7 + 5")
print(7 + 5)2.3 Print exactly: Hours in a week: 168, with Python doing the multiplying.
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("Hours in a week:", 24 * 7)2.4 A cinema has 18 rows of 24 seats. Print two lines, worked out by Python:
Seats: 432
Two shows: 864
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("Seats:", 18 * 24)
print("Two shows:", 18 * 24 * 2)2.5 Asha scored 85, 90 and 77 in three tests. Print her average, worked out by Python (it should show 84.0).
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print((85 + 90 + 77) / 3)Part 3 of 4 · learn, see, practise
Comments, joining and repeating text
A line starting with # is a comment. Python skips it; it is a note for people.
+ between two strings joins them: "ice" + "cream" is "icecream". * repeats a string: "ha" * 3 is "hahaha". Together they draw borders and boxes.
print() with nothing inside prints an empty line.
Output
==================== PYTHON CLUB ==================== +----------+
Memory boxes
The comment prints nothing. Count the characters in the last line: 1 + 10 + 1.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
3.1 Print a line of exactly 15 # signs using * (do not type 15 of them).
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("#" * 15)3.2 Print this box exactly, using * for the dashes:
+----------+
| PYTHON |
+----------+
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("+" + "-" * 10 + "+")
print("| PYTHON |")
print("+" + "-" * 10 + "+")3.3 Print a staircase of five lines: #, ##, ###, ####, ##### (use * on every line).
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
print("#" * 1)
print("#" * 2)
print("#" * 3)
print("#" * 4)
print("#" * 5)3.4 Write a program with at least two comment lines that prints a flag:
*****=====
*****=====
*****=====
Use * to build each line from "*" and "=".
Output
(nothing is printed)
Memory boxes
Model answer (for the teacher)
# my flag
# three equal stripes
print("*" * 5 + "=" * 5)
print("*" * 5 + "=" * 5)
print("*" * 5 + "=" * 5)Part 4 of 4 · learn, see, practise
Reading an error and fixing it
When Python cannot understand a line it stops and shows an error with a line number.
The usual first errors: a missing quote, a missing bracket, Print with a capital P, or text without quotes. Read the line number, compare with a line that works, change one thing, run again.
Output
Line 2: SyntaxError: unterminated string literal
Memory boxes
Run it: the message points at line 2. Add the missing quote and run again.
Practise it
Start with the warm-up and go as far as you can. The stretch questions are meant to be hard.
4.1 Fix the program so it prints: Good morning
Output
Line 1: SyntaxError: unterminated string literal
Memory boxes
Model answer (for the teacher)
print("Good morning")4.2 Fix both lines so the program prints Hello and then World.
Output
Line 2: SyntaxError: expected ')'
Memory boxes
Model answer (for the teacher)
print("Hello")
print("World")4.3 There are three mistakes. Fix them so the output is exactly:
Score: 10
Total: 15
Bye
Output
Line 1: SyntaxError: expected ')'
Memory boxes
Model answer (for the teacher)
print("Score:", 10)
print("Total:", 5 + 10)
print("Bye")Watch out
Common mistakes
Print with a capital P
Print("Hi") does not work. Python is case-sensitive.
Forgetting the quotes
print(Hello) makes Python look for something called Hello. Text needs quotes.
Mixing quote types
print("Hi') starts with " and ends with '. Use the same kind at both ends.
Class activity 1 of 3
Name badge
Build a name badge one step at a time. Press Check after each step to see which parts already work.
- Print a top border of exactly 30 = signs, using *.
- Print NAME: followed by your name on one line.
- Print your age, then on the next line your age in months worked out by Python (age × 12).
- Print one hobby you love.
- Print the bottom border, the same as the top.
Output
(nothing is printed)
Memory boxes
Hint
Each step is one or two print lines. For the months, write print("Age in months:", 11 * 12) with your own age.
Model answer (for the teacher)
# Step 1
print("=" * 30)
# Step 2
print("NAME: Kabir")
# Step 3
print("Age:", 11)
print("Age in months:", 11 * 12)
# Step 4
print("I love: football")
# Step 5
print("=" * 30)Class activity 2 of 3
Shop receipt
Print a receipt that looks exactly like the one below. The total must be worked out by Python.
------------------------
SUPER STATIONERY
------------------------
Pencil 12
Notebook 45
Eraser 8
Total 65
Thank you!
- Print a line of 24 dashes using *.
- Print the shop name, then another line of 24 dashes.
- Print each item and its price on its own line (use a comma between them).
- Print Total and the sum 12 + 45 + 8, worked out by Python.
- Print Thank you! at the end.
Output
(nothing is printed)
Memory boxes
Hint
print("Pencil", 12) prints Pencil 12 with one space.
Model answer (for the teacher)
print("-" * 24)
print("SUPER STATIONERY")
print("-" * 24)
print("Pencil", 12)
print("Notebook", 45)
print("Eraser", 8)
print("Total", 12 + 45 + 8)
print("Thank you!")Class activity 3 of 3
Times-table strip
Print the first six lines of the 7 times table, with Python doing every multiplication:
7 x 1 = 7
7 x 2 = 14
… up to 7 x 6 = 42. Then print a line of 20 stars and the line: Total of the answers: 147 (worked out by Python).
- Print 7 x 1 = and the answer 7 * 1, using a comma.
- Do the same for 2 to 6.
- Print a line of 20 stars.
- Print Total of the answers: and let Python add 7 + 14 + … + 42 (or 7 * 21).
Output
7 x 1 = 7
Memory boxes
Hint
Copy the first line five times and change the numbers.
Model answer (for the teacher)
print("7 x 1 =", 7 * 1)
print("7 x 2 =", 7 * 2)
print("7 x 3 =", 7 * 3)
print("7 x 4 =", 7 * 4)
print("7 x 5 =", 7 * 5)
print("7 x 6 =", 7 * 6)
print("*" * 20)
print("Total of the answers:", 7 + 14 + 21 + 28 + 35 + 42)Quiz · 8 questions
Check what you learned
Pick an answer to see if it is right and why. Your best score is saved on this device.
After class · project
My poster
Make a poster about you or a hobby, drawn with print(). Use the starter code: it already has the sections. Fill each one in.
What to make: A program of at least 12 lines that prints your poster with no errors.
Stretch: Make a border out of two symbols, like "=-" * 13, and a drawing at least 6 lines tall.
How it is marked
| Look for | Done well when |
|---|---|
| Runs | No errors when you press Run |
| Sections | Title, facts, calculation and drawing are all there |
| Comments | Each section has a comment |
| Creative | The poster says something about you |
Starter code to take home
Press Copy and paste it into the editor at home, or work on it right here.
Output
==========================
ALL ABOUT ME
==========================
Name: your name here
My age in days is about 4015
(o.o)
/ | | Memory boxes
Homework
Practise at home
Each one checks itself. Or print the practice sheet.
1. Print a three-line address label: your name, your city and your country.
Output
(nothing is printed)
Memory boxes
2. Print the number of seconds in one day, worked out by Python, with the label Seconds in a day:
Output
(nothing is printed)
Memory boxes
3. Print a hollow square 5 wide, using * and +:
*****
* *
* *
*****
Output
(nothing is printed)
Memory boxes
For parents and teachers
The 60-minute lesson plan
Use it as it is, or stretch any part over two sessions. Each row links to the part of the page you need.
| Time | Part | The teacher | The learner |
|---|---|---|---|
| 0–4 min | Warm-up | Act as the literal robot for the lemonade steps. | Write steps; spot the bugs. |
| 4–13 min | Programs and print | Run the example, then let them do the four practice tasks. | Practise up to the star triangle. |
| 13–22 min | Text and numbers | Ask why lines 1 and 2 differ, then practice. | Do the cinema and average tasks. |
| 22–30 min | Comments and repeating | Count characters in the box together. | Draw the box and the flag. |
| 30–36 min | Fixing errors | Read the error message aloud together. | Fix all three broken programs. |
| 36–44 min | Name badge | Let them follow the steps alone. | Build the badge and press Check. |
| 44–51 min | Shop receipt | Point out the exact output. | Match the receipt exactly. |
| 51–56 min | Times-table strip | If time is short, set it as homework. | Build the strip. |
| 56–59 min | Quiz | Run the quiz. | Answer and read why. |
| 59–60 min | Set the project | Open the starter and agree a due date. | Copy the starter. |
Questions to ask
- What is the difference between print(5 + 3) and print("5 + 3")?
- What does + do between two strings? And *?
- When you see an error, what do you look at first?
If it feels hard
Type the examples together line by line before the practice. Do only levels 1 and 2 in class and set level 3 as homework.
If it feels easy
Ask for a 6-line drawing of a house where every line uses * to repeat a symbol.
FAQ
Hello, Python: print, text and comments: questions
Do we need to install Python for this lesson?
No. Every example, practice task and activity runs on this page in the browser.
What age can start with this Python course?
Learners from about 9 or 10 can follow it with a teacher; older learners and adults can work through it alone.
How is each session organised?
In loops: a short explanation, a runnable example, practice at three levels, then the next idea. Three bigger activities, a quiz and an after-class project end the class.
Start a conversation
Want a teacher to take this class?
Tell us the learner's age and level. A teacher from our network teaches with these lessons; we confirm timing and price first.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian