Python for AIPython 3.10+ · Pydantic 2.12
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
34 small wins to finish your pathNext lesson →

print()

print() is a built-in Python function that shows a value on the screen, and it is the first line most programs start with.

Last updated: 30 Sep, 2026 · Python 3.14

A program is a list of instructions that Python runs from top to bottom. print is how you see what those instructions did.

Syntax:

python
print(value)              # one value
print(value1, value2)     # several, separated by a space

Printing a line of text

Example
print("Hello!")

print shows whatever is inside its brackets. The quotes mark Hello! as text, so Python shows it as it is instead of trying to run it.

Two lines run in the order they are written, and each print starts a new line.

Example
print("Ticket 1: I was charged twice for one order")
print("Ticket 2: My parcel has not arrived")

Printing text and sums

Without quotes, Python works the value out before printing it. With quotes, it is only text that happens to contain a sum.

Example
print(2 + 3)
print("2 + 3")

Adding comments

A # starts a comment. Python ignores everything from there to the end of the line, so comments are notes for whoever reads the code next.

Example
# Tickets that came in overnight
print("Waiting: 3")  # this part is ignored too

Reading your first error

Leave out the closing quote and Python cannot tell where the text ends. It stops before running anything and says so.

Example
print("Hello!)

Read the last line of an error first. It names the kind of problem. The lines above it say where: the file and the line number. On your computer the error shows the full path of your file instead of main.py, and often a row of ^ marks under the exact spot; the last line is the same.

Errors are normal. Most lessons cause one deliberately, because an error you have seen once is easy to recognise the next time.

Text in quotes vs a value

You writeprint showsWhy
print(2 + 3)5Python works out the sum first
print("2 + 3")2 + 3Quotes make it text

Where print() helps in AI code

  • Checking what a model sent back before your program uses it.
  • Following a long run step by step, one line per ticket.
Watch out. Print("Hello") with a capital P is a NameError. Python is case sensitive: print and Print are different names.
Try it yourself
  • Print your own name.
  • Print 10 - 4 with quotes and without them.
  • Delete the closing bracket of a print and read the last line of the error.

You understood something today that you didn't yesterday.