Print Statement | Python Tutorial - Learn with VOKS
Back Next

Print Statement


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:

  • see results of our code
  • test if our program works
  • display messages to users
  • debug (find errors)

Basic Syntax

print(value)

You can print:

  • text
  • numbers
  • variables
  • results of calculations

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:

  • track values
  • find errors

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

In one sentence:

print() is used to display output to the screen in Python.

The most important things to remember:

βœ” 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.")


Python
Intorduction Python Syntax Compare to other Programming Languages How to Install Python Print Statement Python Comments Data Structure and Data Type String Operations in Python Simple Input and Output Simple Output Formatting
All Courses
Advance AI Bootstrap C C++ Computer Vision Content Writing CSS Cyber Security Data Analysis Deep Learning Email Marketing Excel Figma HTML Java Script Machine Learning MySQLi Node JS PHP Power Bi Python Python for AI Python for Analysis React React Native SEO SMM SQL