Console Output

Learn how to print the output on the console in Python.

Print output on the console

The built-in function print() is used to send output to the screen.

The print() function has the following form:

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

This means that, by default, objects will be printed on screen (sys.stdout), separated by a space (sep = ' '), and the last printed object will be followed by a newline (end = '\n'). In the code snippet above, flush = False indicates that the output stream will not be flushed.

Python has a facility to call functions and pass keyword-based values as arguments. While calling print(), we can pass specific values for sep and end. In this case, default values will not be used; instead, the values that we pass will be used.

Get hands-on with 1200+ tech skills courses.