What Is the print() Statement?
πΉ Simple Meaning
The print() function is used to:
display output to the screen.
It is usually the first Python function beginners learn.
Example:
print("Hello, world!")
Output:
Hello, world!
So:
π print() = show something on the screen
Why print() Is Important
We use print() to:
Basic Syntax
print(value)
You can print:
Printing Different Data Types
print("Python") # string
print(10) # integer
print(3.5) # float
Printing Variables
name = "Ada" print(name)
Output:
Ada
Printing Multiple Items
print("My name is", "Ada")
Output:
My name is Ada
Python automatically adds a space between them.
Important Parameters of print()
| Parameter | Meaning (Simple) | Example |
|-----------|-----------------------------------------------|----------------------------------|
| sep | Separates multiple values | print("A","B", sep="-") |
| end | What is printed at the end | print("Hello", end="!") |
| file | Sends output to a file | print("Hi", file=f) |
The sep Parameter
Default separator is a space.
Example:
print("2026", "02", "23", sep="-")
Output:
2026-02-23
The end Parameter
By default, print() ends with a new line.
Example:
print("Hello", end=" ")
print("World")
Output:
Hello World
Printing Calculations
print(5 + 3)
Output:
8
Formatting Output
This is the modern and best way.
name = "Ada"
age = 20
print(f"My name is {name} and I am {age} years old")
Different Ways to Format Strings
| Method | Example | Recommended? |
|---------------|--------------------------------------------|--------------|
| Comma | print("Age:", age) | β
Good |
| f-string | print(f"Age: {age}") | β Best |
| format() | print("Age: {}".format(age)) | π Good |
| % formatting | print("Age: %d" % age) | β Old style |
Printing Quotes
If your text contains quotes:
print("She said 'Hello'")
OR
print('She said "Hello"')
Printing on Multiple Lines
print("Line 1")
print("Line 2")
OR
print("""Line 1
Line 2
Line 3""")
Using print() for Debugging
You can check what is happening in your code:
x = 5 print(x)
This helps you:
Common Beginner Mistakes
| Mistake | Why It Happens | Fix |
|----------------------------------|------------------------------------|---------------------------------------|
| Missing quotes | Python thinks itβs a variable | print("Hello") |
| Wrong case (Print) | Python is case-sensitive | print() not Print() |
| Missing parentheses | Using Python 3 | print() |
| Space in variable name | Invalid syntax | use underscore |
print() in Python 2 vs Python 3
| Python 2 | Python 3 |
|-----------------|-----------------|
| print "Hello" | print("Hello") |
Python 3 uses parentheses β
Real-Life Uses of print()
| Use Case | Example | |------------------------|------------------------------------------| | Showing results | Display total price | | User messages | Welcome screen | | Debugging | Checking variable values | | Learning Python | Understanding program flow |
Final Summary
print() is used to display output to the screen in Python.β It shows results
β It can print text, numbers, and variables
β It supports formatting (f-strings are best)
β It helps in debugging
Most Important Example for Beginners
name = "Danny"
age = 25
print(f"My name is {name} and I am {age} years old.")