Unit 1: Hello, Python
Make the computer talk.
Unit 1 of 31 in Python for kids. Its 5 lessons are Printing, Boxes for Stuff, Words & Text, Neat Printing and Greeting Machine — below is everything each one explains, and a question or two from it to try.
Every sample on this page was run through real Python before it shipped, and prints exactly what it says it prints.
This unit is free for ever, because the first two units of every track are. Try it in the app.
💬 Printing
Make the computer speak
print tells the computer to say something out loud on the screen. Put the words inside quotes and inside the round brackets.
Python
print("Hello!")
It prints
Hello!
Try it yourself
What does this show on the screen?
Python
print("Pizza")
- "Pizza"
- Pizza
- Nothing
Which line is broken?
- print("cat")
- print(cat")
- print("dog")
Answer them in the app
📦 Boxes for Stuff
Variables are labelled boxes
A variable is a box with a name on it. You put something in with =, then use the name whenever you want what is inside.
Python
score = 10
print(score)
It prints
10
Try it yourself
What does this print?
Python
pets = 3
print(pets)
- pets
- 3
- "pets"
- nothing
What does this print?
Python
print(2 + 3)
- 2 + 3
- 23
- 5
- 6
Answer them in the app
🔤 Words & Text
Sticking words together
Text in quotes is called a string. You can glue strings together with +. Remember the space, or the words squash into each other!
Python
name = "Ada"
print("Hi " + name)
It prints
Hi Ada
Try it yourself
What does this print?
Python
print("cat" + "fish")
Which one prints: I love pizza
Python
food = "pizza"
- print("I love " + food)
- print("I love " + "food")
- print("I love food")
- print(I love + food)
Answer them in the app
🏷️ Neat Printing
Notes to yourself
Anything after a # is a comment. Python skips it completely — it is a note for whoever reads the code later, which is usually you next week.
Python
# work out the score
score = 10
print(score) # show it
It prints
10
A tidier way to mix words and values
Gluing with + gets fiddly fast, and it breaks the moment a number is involved. Put an f before the quotes and you can drop values straight in with { }.
Python
name = "Ada"
age = 12
print(f"{name} is {age}")
It prints
Ada is 12
Try it yourself
What does Python do with the part after #?
- Prints it
- Ignores it completely
- Turns it red
- Stops the program
What does this print?
Python
pet = "cat"
legs = 4
print(f"My {pet} has {legs} legs")
Answer them in the app
🏆 Greeting Machine
Try it yourself
Quick warm-up. What does this print?
Python
x = 4
y = 6
print(x + y)
- 46
- 10
- x + y
- 2
What does this print?
Python
a = "5"
b = "5"
print(a + b)
Answer them in the app