Python print() Function Syntax

Syntax : print(value(s), sep= ‘ ‘, end = ‘\n’, file=file, flush=flush)

Parameters: 

  • value(s): Any value, and as many as you like. Will be converted to a string before printed
  • sep=’separator’ : (Optional) Specify how to separate the objects, if there is more than one.Default :’ ‘
  • end=’end’: (Optional) Specify what to print at the end.Default : ‘\n’
  • file : (Optional) An object with a write method. Default :sys.stdout
  • flush : (Optional) A Boolean, specifying if the output is flushed (True) or buffered (False). Default: False

Return Type: It returns output to the screen.

Though it is not necessary to pass arguments in the print() function, it requires an empty parenthesis at the end that tells Python to execute the function rather than calling it by name. Now, let’s explore the optional arguments that can be used with the print() function.

Example

In this example, we have created three variables integer, string and float and we are printing all the variables with print() function in Python.

Python3
name = "John"
age = 30

print("Name:", name)
print("Age:", age)

Output
Name: John
Age: 30


Python | Output using print() function

Python print() function prints the message to the screen or any other standard output device. In this article, we will cover about print() function in Python as well as it’s various operations.

Similar Reads

Python print() Function Syntax

Syntax : print(value(s), sep= ‘ ‘, end = ‘\n’, file=file, flush=flush) Parameters:  value(s): Any value, and as many as you like. Will be converted to a string before printedsep=’separator’ : (Optional) Specify how to separate the objects, if there is more than one.Default :’ ‘end=’end’: (Optional) Specify what to print at the end.Default : ‘\n’file : (Optional) An object with a write method. Default :sys.stdoutflush : (Optional) A Boolean, specifying if the output is flushed (True) or buffered (False). Default: FalseReturn Type: It returns output to the screen....

How print() works in Python?

You can pass variables, strings, numbers, or other data types as one or more parameters when using the print() function. Then, these parameters are represented as strings by their respective str() functions. To create a single output string, the transformed strings are concatenated with spaces between them....

Python print() Function with Examples

Python String Literals...