Lesson 14 of 70 – Python Output
20%

Python Output

In Python, output means displaying information on the screen. The most commonly used function for displaying output is print().

Note: The print() function can display text, numbers, variables, expressions, multiple values, and formatted strings.
What is Output?

Output is the information displayed by a program after processing data.

For example:

print("Hello World")
Output:
Hello World
The print() Function

The print() function is used to display information on the screen.

print("Welcome to Python")
Output:
Welcome to Python

You can use print() as many times as required.

print("Hello")
print("Welcome")
print("Python")
Output:
Hello
Welcome
Python
Printing Text

Text is written inside quotation marks when using the print() function.

print("My name is Rahul")
print("I am learning Python")
Output:
My name is Rahul
I am learning Python
Printing Numbers

Numbers can be printed without quotation marks.

print(10)
print(100)
print(99.50)
Output:
10
100
99.5
Printing Variables

The print() function can display the value stored in a variable.

name = "Rahul"
age = 20

print(name)
print(age)
Output:
Rahul
20
Printing Multiple Values

You can pass multiple values to print(). Python separates them with a space by default.

name = "Rahul"
age = 20

print(name, age)
Output:
Rahul 20
Printing Text and Variables

You can print text and variables together.

name = "Rahul"
age = 20

print("Name:", name)
print("Age:", age)
Output:
Name: Rahul
Age: 20
Printing Expressions

The print() function can also display the result of an expression.

print(10 + 20)
print(50 - 20)
print(5 * 4)
Output:
30
30
20
Printing Calculations
a = 10
b = 20

print("Sum:", a + b)
print("Difference:", a - b)
print("Product:", a * b)
Output:
Sum: 30
Difference: -10
Product: 200
The sep Parameter

The sep parameter controls what is placed between multiple values printed by print().

print("Python", "Java", "PHP", sep=", ")
Output:
Python, Java, PHP

By default, the separator is a space.

Using sep with a Symbol
print("2026", "09", "20", sep="-")
Output:
2026-09-20

You can use different characters as a separator.

The end Parameter

By default, print() moves to a new line after displaying output. The end parameter can change this behavior.

print("Hello", end=" ")
print("World")
Output:
Hello World
Using end with Symbols
print("Python", end=" - ")
print("Programming")
Output:
Python - Programming
New Line Character \n

The \n escape sequence is used to create a new line.

print("Hello\nWorld")
Output:
Hello
World
Tab Character \t

The \t escape sequence inserts a tab space.

print("Name\tAge")
print("Rahul\t20")
Output:
Name    Age
Rahul    20
Printing Quotes

You can use different quotation marks to display quotes inside a string.

print('He said "Hello"')
Output:
He said "Hello"

You can also use escape characters when necessary.

print("He said \"Hello\"")
Output:
He said "Hello"
Output Using f-Strings

F-strings provide a convenient way to insert variables inside strings.

name = "Rahul"
age = 20

print(f"My name is {name}.")
print(f"I am {age} years old.")
Output:
My name is Rahul.
I am 20 years old.
Printing a List

The print() function can display collection data such as lists.

fruits = ["Apple", "Banana", "Mango"]

print(fruits)
Output:
['Apple', 'Banana', 'Mango']
Practical Output Example
name = "Rahul"
age = 21
course = "Python"

print("----- Student Details -----")
print("Name:", name)
print("Age:", age)
print("Course:", course)
print("Status:", "Active")
Output:
----- Student Details -----
Name: Rahul
Age: 21
Course: Python
Status: Active
Key Points
  • The print() function is used to display output.
  • Text is normally written inside quotation marks.
  • Variables can be displayed using print().
  • Multiple values can be printed together.
  • The sep parameter controls the separator between values.
  • The end parameter controls what is printed after the output.
  • \n creates a new line.
  • \t creates a tab space.
  • F-strings can be used to create formatted output.
  • The print() function can display expressions and calculations.

🧠 Quick Quiz

Question: Which function is used to display output in Python?