Easy Tutorial
❮ Python Os Pardir Python Loop ❯

Python print() Function

Python3 Built-in Functions


Description

The print() method is used for printing output, one of the most common functions.

The flush keyword argument was added in Python3.3.

>

In Python3.x, print is a function, but in Python2.x, it is not a function but a keyword.

Syntax

Here is the syntax for the print() method:

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)

Parameters

Return Value

None.


Examples

Below are examples of using the print function:

Test in Python3

>>> print(1)  
1  
>>> print("Hello World")  
Hello World  

>>> a = 1
>>> b = 'tutorialpro'
>>> print(a,b)
1 tutorialpro

>>> print("aaa""bbb")
aaabbb
>>> print("aaa","bbb")
aaa bbb
>>> 

>>> print("www","tutorialpro","com",sep=".")  # Set separator
www.tutorialpro.org

Using the flush parameter to create a Loading effect:

Example

import time

print("---tutorialpro EXAMPLE: Loading Effect---")

print("Loading",end = "")
for i in range(20):
    print(".",end = '',flush = True)
    time.sleep(0.5)

The effect is shown in the following image:

More content can be found at: Python3 print Function Usage Summary

Python3 Built-in Functions

❮ Python Os Pardir Python Loop ❯