KP

Python Output and Print Function Explained

By Krishnamohan Yagneswaran
Tech Blog

Python Output / Print

Printing Text in Python

Python uses the print() function to display text or values on the screen. This function sends output to the console so users can see results while a program is running.

A simple example of printing text looks like this:
"print("Learning Python step by step")"

You can call the print() function multiple times in a program. By default, each call prints its output on a new line.

For example:
"print("Welcome to Python")"
"print("This is your first output lesson")"
"print("Practice makes learning easier")"

Each statement produces output on a separate line.


Using Quotes in Print Statements

In Python, text values must always be placed inside quotes. You can use either double quotes or single quotes, and both work the same way.

Examples of valid text output include:
"print("Python syntax is clear")"
"print('Quotes are required for text')"

If text is written without quotes, Python will not understand it as a string and will raise a syntax error.

An incorrect example would be:
"print(Python is powerful)"

This causes an error because Python treats the words as undefined names instead of text.


Printing Without a New Line

By default, the print() function moves the cursor to a new line after displaying output.

If you want multiple outputs to appear on the same line, you can change this behavior using the end parameter.

For example:
"print("Loading", end="... ")"
"print("completed")"

In this case, both outputs appear on the same line instead of being separated.

This feature is useful when formatting messages, progress indicators, or combined outputs.


Share this post:Share on TwitterShare on LinkedIn