CurriculumPython Variables for KidsBoxes and print, together
Combining Several Python Variables in One print()
Several boxes at once — sentences, stat sheets, and combined totals.
Boxes and print, together
You have used one box at a time so far. Now let us use several together.
print() can take many things at once, remember — boxes and words, mixed freely.
name = "Ember"
age = 200
print(name, "is", age, "years old")Output
Ember is 200 years oldNotice: name and age have NO quotes because they are boxes. The other words DO, because they are just text.
print(name, "is", age, "years old")You can also combine two boxes into a brand new number.
pile_one = 120
pile_two = 35
print(pile_one + pile_two)Output
155Python reads BOTH boxes, adds them together, then says the answer. Neither box changes.
print(pile_one + pile_two)Check your understanding
What will I say here?
coins = 40
gems = 10
print(coins + gems)Why: Python reads both boxes, adds 40 and 10, and says the result: 50. Both boxes stay unchanged.
What will I say here?
name = "Ember"
print(name, "the dragon")Why: name has no quotes, so I look inside it: Ember. The rest has quotes, so I say those words exactly. Together: Ember the dragon.
What you'll practice
The dragon has a name AND an age now. Say both together, on one line, properly labelled so it reads like a sentence.
More from this topic
Boxes and print, together is one lesson inside Python Variables for Kids — see the full lesson order and what the whole topic covers.
View the full topic →