Python print function
Python print() function
To print objects to the standard output screen or to the stream file we use python print() function.
Syntax of the python print() function
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Parameters of the print() function
As you can see into the syntax, there are five parameters which we can pass to the print() function
Whatever object which you want to print on the screen or to the file. Here you can see the print function prefixed with the asterisk (*). Which says that you can pass more than one object.
sep means separator which default value you can see one space.
After every print statement what you want to print that you will define in end parameter. The default value of the print statements is Newline (\n)
By using file parameter you can write your output into the file stream. By default its value is sys.stdout, It means output will be printed onto system's standard output stream, means will be printed on the console.
It takes either True or False. When the value will be true stream will forcefully flushed. By default its value is False.
Example : Simple print() function
Example: multiple objects passing in print() without the separator
Example: Using "sep" parameter
Example: Understanding "end" parameter
Example: Writing file using print()
What python print() function returns?
Python print() function returns None
Example: returning value from the print function