Lesson 4 of 18 · 2 min
print() — Displaying Output on Screen
The WHY — Why Do We Need print()?
Python works silently in the background. When it runs your code, it does not automatically show you anything. print() is your way of saying: "Python, show me this value on the screen right now."
Think of it like the "display" button on your calculator — without it, you do computations but see nothing.
Your Very First Program
print("Hello, World!") # display the text Hello, World! on the screenOutput: Hello, World!
By tradition, every programmer's first program is "Hello, World!" It proves Python is installed and working.
Printing Different Types of Data
print("Ahmed") # print text (a string — always in quotes)
print(42) # print a whole number (an integer)
print(3.14) # print a decimal number (a float)
print(True) # print a yes/no value (a boolean)
print() # print nothing — creates a blank lineOutput: Ahmed 42 3.14 True
Printing Multiple Items at Once
name = "Priya" # store the name in a variable
age = 20 # store the age in a variable
print("Name:", name, "Age:", age) # print label, value, label, value
Output: Name: Priya Age: 20
When you separate items with commas inside print(), Python automatically puts a space between each one.
The sep Parameter — Custom Separator
sep (short for "separator") controls what goes between each printed item:
print("2026", "08", "09", sep="-") # use dash between items
print("A", "B", "C", sep=", ") # use comma-space between items
print("Hello", "World", sep="") # use nothing (no space at all)
Output: 2026-08-09 A, B, C HelloWorld
The end Parameter — What Comes After
By default, print() ends with a new line (moves to the next line). end lets you change this:
print("Loading", end="") # do NOT add new line after "Loading"
print("...") # appears on the SAME line as "Loading"
print("A", end=" | ") # end with " | " instead of new line
print("B", end=" | ") # B also ends with " | "
print("C") # C ends with default new line
Output: Loading... A | B | C
