Learning LibraryCore Coding LibraryKids

print(): put words and numbers on the screen

print() is how your program talks. Every sign, receipt, and message a program shows starts with this one command.

The big idea

print() shows whatever is inside its parentheses in the output console, then moves to a new line.

See it in code

1Start simple

Put words inside quotes, inside the parentheses. Each print line makes one line in the output console:

python
print("=== ELECTRIC BAKERY ===")
print("Fresh cookies today")
Two print lines, two lines of output:
=== ELECTRIC BAKERY ===
Fresh cookies today

Lines run in order, from the top down. The first print in your code is the first line on the screen.

2A step further

Numbers don't need quotes. And one print can show two things if you put a comma between them:

python
print(12)
print("Cookies left:", 12)
A number alone, then words and a number together:
12
Cookies left: 12

The comma does two jobs. It separates the two things, and it adds a space between them for you.

3In the bakery

A real sign keeps its values in variables, so one change updates every line that uses it:

python
sign_title = "=== ELECTRIC BAKERY ==="
special = "brownies"
cookies = 12

print(sign_title)
print("Today's special:", special)
print("Cookies left:", cookies)
The shop sign, with every value in a variable:
=== ELECTRIC BAKERY ===
Today's special: brownies
Cookies left: 12

print(sign_title) shows what the variable holds, not the word sign_title. Quotes mean "show these exact words." No quotes means "look this name up."

The same idea, everywhere

Printing is also how coders check their work. When a program does something odd, a quick print of a variable shows what the program is really holding.

Try it yourself

Add a fourth line to the sign that prints "Cookie of the day:" and a flavor you choose. Then move your new line to the top and run it again. What changed?

The common mistake

Leaving the quotes off words. print(Fresh cookies today) confuses Python, because without quotes it thinks those are names it should look up. Words always go in quotes.

What it unlocks

Next, make your output neater with f-strings, which drop values right into a sentence. And when something breaks, print() is your first tool for debugging.

Older, or want more depth? Read the Teens version →