Technical Roadmap

Output in Python

We use the print() function to display information on the screen.

Providing Output: The print() Function

To display information on the screen, we use the print() function.

You can pass strings, numbers, or variables inside it. By default, the print() function adds a new line after the output.

The Logicoria Tip

You can use the sep (separator) and end parameters to control exactly how your output looks. For example, end=" " keeps the next print on the same line!

Python program to display information

PYTHON
# Basic Print
print("Welcome to Logicoria!")

# Multiple Values (Comma separated)
print("Total Articles in Logicoria:", 100)

# Custom Separator
print("01", "01", "2026", sep="-")

Output

Welcome to Logicoria!
Total Articles in Logicoria: 100
01-01-2026

Advanced Output: String Formatting (f-strings)

We can also use f-strings inside the print() function to output the value of a variable inside a String.

They provide a modern way to embed variables directly by using an f before the quotes and curly brackets {}.

PYTHON
# 1. Define the variables
site_name = "Logicoria"
topic = "Python"
# 2. Use the f-string
print(f"Welcome to {site_name}! We are learning {topic}.")

Output

Welcome to Logicoria! We are learning Python.

Characteristics of print():

  • Flexible Input:
    • Can display text (Strings), numbers, or variables • Multiple items can be separated by commas
  • Default Newline:
    • Automatically adds a line break after printing • Can be changed using the end parameter
  • Custom Separators:
    • Uses a space between items by default • Can be changed using the sep parameter (e.g., sep="-")

Quick Revision

  • Used to show data to the user.
  • Can print multiple items at once.
  • Automatically moves to the next line.
  • Supports modern formatting like f-strings.
  • print() = Sends data to the screen.
  • Comma (,) adds a space between values.
  • f"Text {variable}" is the best way to format output.
  • Use sep to change the gap between items.

Related Articles