
Print Statements in Python
The print() function is used to display information on the screen. It is one of the first and most commonly used functions in Python.
1. Printing Text
We can use print() to display text.
print("Hello, World!")Output:
Hello, World!2. Printing Variables
We can also print the value stored in a variable.
name = "Vishnu"
age = 21
print(name)
print(age)Output:
Vishnu
213. Printing Multiple Values
We can print multiple values using commas.
name = "Vishnu"
age = 21
print("Name:", name, "Age:", age)Output:
Name: Vishnu Age: 214. Using sep
The sep parameter is used to change the separator between multiple values.
print("Python", "Java", "C++", sep=" - ")Output:
Python - Java - C++5. Using end
Normally, print() moves to a new line after displaying something. The end parameter can change this behavior.
print("Hello", end=" ")
print("World")Output:
Hello World6. Printing Calculations
We can also print the result of calculations.
a = 10
b = 5
print(a + b)
print(a * b)Output:
15
50Join Techsnap Creators
Share your knowledge and earn ??
Want to showcase your tech expertise and get rewarded for your insights? Join the Techsnap creator network!
Write insightful blogs, stay ahead of industry trends, and grow your professional brand while helping others in the community.
Ready to make an impact?

Comments