Print Function Basics

Introduction to print()

The print() function in Python is one of the most fundamental and frequently used functions. It outputs text and variables to the console.

print("Hello, World!")
Hello, World!
Read more about Print Basics

Advanced Print Features

Separator and End Parameters

Control output formatting with sep and end parameters:

print("Hello", "World", sep="-", end="!")
Hello-World!

Variables in Print

Python's print function can easily display variables of any type. Variables are automatically converted to their string representation.

number = 42 name = "Python" print(number) print("Value:", number) print(f"I love {name}!")
42 Value: 42 I love Python!
Read more about Varibles

Common Examples

Printing Variables

age = 25 print("Age:", age)
Age: 25

Multiple Arguments

Use multiple arguments to print several items at once:

print("Python", "is", "awesome")
Python is awesome
More Examples

Try It Yourself!

Print Command History

1991

Python's First Release

Python was first released by Guido van Rossum, introducing the print statement as a basic feature. At this time, print was a statement rather than a function, using a simpler syntax without parentheses. This made it easy for beginners but limited its functionality.

2000-2007

Print Statement Era

During this period, the print statement was widely used in Python 2.x. It had some limitations, such as no easy way to change the output stream or end character. Developers had to use sys.stdout.write() for more advanced output control.

2008

PEP 3105 Introduction

Python Enhancement Proposal 3105 was introduced, suggesting the transformation of the print statement into a function. This was a controversial change that sparked much debate in the Python community about backward compatibility versus language consistency.

2010

Python 3 Print Function

With Python 3's release, print officially became a function. This change brought new capabilities like the sep, end, and file parameters. It allowed for more flexible output formatting and better integration with file-like objects.

2020-Present

Modern Print Usage

Today, the print function is one of Python's most versatile tools. It supports Unicode, multiple output streams, and various formatting options. It's extensively used in debugging, logging, and user interaction, making it an essential part of Python programming.