Python print() function
Python print() function
The print() function prints the specified message to the screen or other standard output devices.
Syntax
print(*objects,sep=' ',end='\n',file=sys.stdout,flush=False)
Parameter
objects: This function represents an object, which will be converted to a string before printed.
sep: It is an optional parameter that specifies how to separate the objects if there is more than one. The default value of this function is ' '
end: It is an optional parameter that specifies what to print at the end. The default value of this function is '\n'.
file: This parameter represents an object with a write method, and by default,its value is sys.stdout.
flush: It is an also an optional parameter which represents a Boolean value, specifying if the output is flushed (True) or buffered (False). The default value of this attribute is False.
Return
This function returns output to the screen.
Example 1
#Python Program explaining # the print() function # passing one object print ("Helloworld") # passing Four objects print ("This", "is", "a", "print", "function","example") # priting integer value num = [1, 2, 3, 4, 5] # printing a list print(num)
Output
Helloworld This is a print function example [1, 2, 3, 4, 5]