Stop 01 · Python FoundationsTopics · 5/8

Your First Program with print()

Part of the Python Roadmap

In short

print() is the first thing every Python learner types and the last thing senior developers stop using. It is how your program talks back to you, and the quickest way to see what is going on inside it.

print() writes text and values to the screen, and it is the first tool you use to see what your program is doing. It accepts several values, plus sep and end options to control spacing and line breaks.

The jaadu stands on a railway platform speaking into a big brass megaphone while travellers with suitcases turn to listen.

Think of it like this

The station announcer

At a railway station, everything happening behind the scenes stays invisible until the announcer speaks: "Train 12951 to Mumbai is on platform 3." print() is your program's announcer. It takes whatever you hand it, joins the pieces with spaces, and says it out loud on the screen.

Watch it happen

What print("Chai", 20, sep=" - ", end="!\n") does

Values in
Turn into text
Join with sep
Add end
Screen

1/5print receives two values: the string "Chai" and the integer 20.

The big ideas

What you need to know

Text needs quotes

"Hello" and 'Hello' are both strings. Without quotes, Python thinks Hello is a variable name and raises a NameError.

Many values, one call

print("Total:", 150, "rupees") prints all three separated by spaces. Numbers don't need to be turned into text first.

sep controls the glue

sep="-" joins values with a dash, sep="" with nothing. Handy for dates, file paths and tables.

end controls the line ending

Each print ends with a newline by default. end="" or end=" " keeps the next print on the same line.

See it in code

Walk through the code

python
1print("Namaste, world!")2print("Chai", "costs", 20, "rupees")3print("2026", "11", "24", sep="-")4print("Loading", end="...")5print("done!")6print()7print("Total:", 150 + 45)

1/6The simplest print: one string in quotes.

Output: Namaste, world! / Chai costs 20 rupees / 2026-11-24 / Loading...done! / an empty line / Total: 195

Save yourself the pain

Common mistakes

Oops

print "Hello" without brackets, copied from an old Python 2 tutorial.

Do this instead

In Python 3, print is a function: print("Hello"). The brackets are required.

Oops

Mixing quote types like print("Hello') and getting a SyntaxError.

Do this instead

Open and close with the same quote. Use the other type inside: print("It's chai time").

Oops

Writing print("Total: " + 195) and getting a TypeError.

Do this instead

+ can't join text and a number. Use commas, print("Total:", 195), or an f-string you'll meet soon.

Your mission

Print a train ticket

~15 min

Quick check

What does print("a", "b", "c", sep="") show?

Go deeper

  1. 1Print your name, city and favourite food on separate lines.
  2. 2Pass several values to one print() and change sep to ' | ' to see the effect.
  3. 3Use end='' to print two things on the same line.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge