print() Function in python is used to print anything in the console or screen.

the print() function is one of the most important and useful function in python.

In python2 print is a keyword but from python3 print is treat as function. this is basic difference between python2 and python3.

let’s write our first program using the print() function in python

print("Hello world")


Hello world

NOTE: It is compulsory to write a string inside a single quote (‘…’) or double quote (“…”) otherwise it will give an error.

Perform arithmetic operation inside print() function

you can also perform arithmetic operation such as addition, subtraction, multiplication, division, etc inside print() function.

print(2+3) #5
print(3+5+1) #9
print(5-7) #-2
print(7-1) #6
print(3*4) #12
print(10/5) #2.0

You can also concatenate two strings inside the print() function.

first_name = "allin"
last_name = "python"
print(first_name + last_name)



Print Python Escape Characters as a normal character

\n, \r, \ t all are python escape characters we are writing a program to print those escape characters as normal characters.




print() function without new line

Let’s understand how to print multiple print statements in a single line with the help of an example.

print("this is fist line ", end="-->")
print("this is second line")


this is fist line -->this is second line

the end is an attribute of the print() function that voids (or prevents) printing in the next line.

Instead of writing "-->", you can write any other characters for example (*, &, #, etc..,).

Without using the end attribute output of the above program…

print("this is fist line ")

print("this is second line")


this is fist line 
this is second line

Hope this content add some value to your life – thankyou.


Hi, I'm Yagyavendra Tiwari, a computer engineer with a strong passion for programming. I'm excited to share my programming knowledge with everyone here and help educate others in this field.

1 Comment

Write A Comment