Member-only story

Everything You Need to Know About Python’s print() Function

Allwin Raju
2 min readJan 2, 2025

--

Photo by Mohammad Rahmani on Unsplash

Read for free: https://allwin-raju.medium.com/everything-you-need-to-know-about-pythons-print-function-1ae9692b71f3?sk=85800ba207f6a250b4ff8915e1fcd3ff

The print function in Python is one of the most commonly used built-in functions. It outputs text or other data to the console or a specified file-like object. Here's a detailed overview:

Syntax of print() Function

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

Parameters

*objects:

  • Accepts one or more objects to print. These objects are converted to strings and displayed.
print("Hello", "World", 123)
# Output: Hello World 123

sep (optional):

  • Specifies the separator between objects. Default is a space (' ').
print("Hello", "World", sep="-")
# Output: Hello-World

end (optional):

  • Specifies the string appended at the end of the output. The default is a newline ('\n').
print("Hello", end=" ")
print("World")

# Output: Hello World

file (optional):

  • Specifies the file-like object to write the output. Default…

--

--

Responses (1)