0
0
PythonHow-ToBeginner · 3 min read

How to Print Output in Python: Simple Guide

In Python, you print output using the print() function. You put the text or values you want to show inside the parentheses, like print('Hello').
📐

Syntax

The basic way to print output in Python is by using the print() function. Inside the parentheses, you put what you want to show on the screen. This can be text (called a string), numbers, or variables.

  • print(): The function that shows output.
  • Text or values inside parentheses: What you want to display.
  • Strings: Text must be inside quotes, like 'Hello' or "Hello".
python
print('Hello, world!')
Output
Hello, world!
💻

Example

This example shows how to print a simple message and a number. It also shows how to print multiple items separated by spaces.

python
print('Welcome to Python!')
print(123)
print('Number:', 123)
Output
Welcome to Python! 123 Number: 123
⚠️

Common Pitfalls

Some common mistakes when printing in Python include:

  • Forgetting quotes around text, which causes errors.
  • Using commas inside strings instead of separating items in print().
  • Trying to print variables without defining them first.

Here is an example of a wrong and right way:

python
# Wrong: missing quotes around text
# print(Hello)

# Right: text inside quotes
print('Hello')
Output
Hello
📊

Quick Reference

Remember these tips when printing in Python:

  • Use print() to show output.
  • Put text inside quotes.
  • Separate multiple items with commas inside print().
  • Variables can be printed directly.

Key Takeaways

Use the print() function to display output in Python.
Put text inside quotes when printing strings.
Separate multiple items with commas inside print().
Always define variables before printing them.
Common errors come from missing quotes or undefined variables.