Notes

Printing in Python [ English ]

< Prev Next >

1. Introduction

In Python, printing refers to displaying output on the screen. This is done using the built-in print() function. It is one of the most commonly used functions and is essential for displaying messages, results, and program outputs.

2. The print() Function

The print() function is used to display text, numbers, variables, and other data types on the screen.

Syntax

print(object(s), sep=separator, end=end_character)

3. Parameters of print()

  1. object(s) The data to be printed (strings, numbers, variables, etc.)

  2. sep (optional) Specifies the separator between multiple values Default value: space " "

  3. end (optional) Specifies what to print at the end Default value: newline \n

4. Basic Example

print("Hello, World!")

Output

Hello, World!

Explanation

5. Printing Multiple Values

print("Python", "is", "easy")

Output

Python is easy

Explanation

6. Using sep Parameter

print("2026", "03", "20", sep="-")

Output

2026-03-20

Explanation

7. Using end Parameter

print("Hello", end=" ")
print("World")

Output

Hello World

Explanation

8. Printing Variables

name = "Rahul"
age = 20

print("Name:", name)
print("Age:", age)

Output

Name: Rahul
Age: 20

9. Printing Different Data Types

print(10)
print(3.14)
print(True)

Output

10
3.14
True

10. Using Formatted Strings (f-strings)

name = "Amit"
marks = 85

print(f"Name: {name}, Marks: {marks}")

Output

Name: Amit, Marks: 85

Explanation

11. Printing Escape Characters

print("Hello\nWorld")

Output

Hello
World

Common Escape Characters

Escape Meaning
\n New line
\t Tab space
\\ Backslash

12. Summary

< Prev Next >