The print()
function in Python converts the given object(s) to a string first before printing it (them) to the screen.
The syntax of print()
function is:
print(Object(s), sep=‘ ‘, end=‘\n’, file=sys.stdout, flush=False)
Object(s)
- Object(s) to be printed on the screen.
sep
- object(s) are printed separately with the separator in between, and the default value is ‘ ’. (optional)
end
- end is printed at last, and the default value is ‘/n’.(optional)
file
- Object with a write(string) function, and the default value is sys.stdout
. (optional)
flush
- If True, the stream is flushed otherwise buffered and the default value is False. (optional)
print()
function in Python returnsNone
.
print("Educative")
print("Educative", "provides interactive courses.")
print("Educative", "Provides interective courses.", sep=": ")
end
parameter:print("Educative", end=' !!')
# Creating output filewith open('output/output.txt', 'w') as f:print('Educative', file=f) # Printing Educative in output.txt file
Free Resources