Python Output Using print()

Ka Kavitha V Updated 03 Oct 2026
6 min read ·Lesson 3 of 23
In this post

Python Output Using print() In Python, the print() function is used to display messages, values, and results on the screen. It is one of the most basic and frequently used functions in any Python prog

Output Using print()

In Python, the print() function is used to display messages, values, and results on the screen. It is one of the most basic and frequently used functions in any Python program — you will use it to show results to users, check the value of variables, and debug your code.

What Is the print() Function?

print() is a built-in function, which means it is always available; you do not need to import anything to use it. You place the value you want to display inside the parentheses, and Python writes it to the standard output — usually your terminal or console window.

Syntax

print(value1, value2, ..., sep=" ", end="\n")
PartMeaning
value1, value2, ...One or more values to display
sepText placed between values (default: a single space)
endText placed after the last value (default: a newline, \n)

You do not need to write sep or end unless you want to change their default behavior.

Example: Printing a Message

print("Welcome to Python Programming")

Expected output:

Welcome to Python Programming

Calling print() Multiple Times

You can call print() as many times as you need. Each call displays its output on a separate line by default.

print("Python is easy to learn")
print("It is powerful and flexible")
print("I enjoy writing Python code")

Expected output:

Python is easy to learn
It is powerful and flexible
I enjoy writing Python code

Each output appears on its own line because print() automatically adds a newline character at the end of its output. You will see how to change this later in this lesson.

You can also call print() with nothing inside the parentheses to print an empty line:

print("First line")
print()
print("Third line")

Expected output:

First line

Third line

Using Quotes for Text

Text in Python is called a string. Any string you want to print must be enclosed in quotation marks. Python accepts either double quotes (" ") or single quotes (' ').

print("Learning Python step by step")
print('This message also prints correctly')

Expected output:

Learning Python step by step
This message also prints correctly

Both styles work the same way. Choose one style and use it consistently.

Having two quote styles is useful when the text itself contains a quote character:

print("It's a great day to learn Python")
print('She said, "Python is fun!"')

Expected output:

It's a great day to learn Python
She said, "Python is fun!"
  • The first string contains an apostrophe ('), so it is wrapped in double quotes.
  • The second string contains double quotes, so it is wrapped in single quotes.

What Happens If You Forget the Quotes?

If you forget the quotes, Python does not treat the text as a string. Instead, it tries to interpret the words as code — such as variable names or keywords — and raises an error.

print(Hello World)

Output:

SyntaxError: invalid syntax. Perhaps you forgot a comma?

Python sees two separate names, Hello and World, written next to each other, which is not valid code.

Even a single unquoted word causes an error:

print(Hello)

Output:

NameError: name 'Hello' is not defined

Here the syntax is valid, but Python looks for a variable called Hello. Because no such variable exists, it raises a NameError.

Remember: Without quotes, Python reads text as code. With quotes, Python reads text as data.

Printing on the Same Line With end

Normally, print() moves the cursor to a new line after printing. You can change this behavior with the end parameter, which controls what is printed after the output.

print("Good Morning", end=" - ")
print("Have a great day!")

Expected output:

Good Morning - Have a great day!

How it works:

  1. The first print() displays Good Morning.
  2. Instead of adding a newline, it adds the value of end, which is " - ".
  3. The cursor stays on the same line, so the second print() continues there.

The end value replaces the default newline. Adding spaces or symbols inside end improves readability. If you use end="", the outputs are joined with nothing between them:

print("Py", end="")
print("thon")

Expected output:

Python

Practical Example: Printing a Sequence on One Line

for number in range(1, 6):
    print(number, end=" ")

Expected output:

1 2 3 4 5 

Without end=" ", each number would appear on its own line.

Printing Numbers

The print() function is not limited to text. It can also display numeric values such as integers and decimal numbers. Numbers are not written inside quotation marks.

print(7)
print(120)
print(9846)
print(3.75)

Expected output:

7
120
9846
3.75

Numbers vs Numeric Strings

Notice the difference between a number and a string that looks like a number:

print(5 + 5)
print("5" + "5")

Expected output:

10
55
  • 5 + 5 adds two numbers, giving 10.
  • "5" + "5" joins two strings, giving "55".

This is why quotes matter: they change the type of the value and how Python treats it.

Printing Calculations

You can perform arithmetic directly inside print(). Python evaluates the expression first and then displays the result.

print(10 - 4)
print(6 * 8)
print(20 // 3)

Expected output:

6
48
6
  • 10 - 4 subtracts and gives 6.
  • 6 * 8 multiplies and gives 48.
  • 20 // 3 performs floor division, which divides and discards the decimal part, giving 6. (Regular division, 20 / 3, would give 6.666666666666667.)

This makes print() very useful for checking calculations while learning or debugging.

Combining Text and Numbers

You can display text and numbers together by separating them with commas inside print(). Python converts each value to text and places a space between them automatically.

print("My score is", 92)
print("Total items:", 15, "units")

Expected output:

My score is 92
Total items: 15 units

Using commas is a simple and safe way to mix different data types in one output.

Why Not Use +?

The + operator can only join strings with other strings. Trying to join a string and a number with + causes an error:

print("My score is " + 92)

Output:

TypeError: can only concatenate str (not "int") to str

To use +, you must first convert the number to a string with str():

print("My score is " + str(92))

Expected output:

My score is 92

Commas are simpler for beginners. Later, you will learn f-strings, which are the most common way to combine text and values:

score = 92
print(f"My score is {score}")

Expected output:

My score is 92

Changing the Separator With sep

When you pass several values, print() puts a space between them. The sep parameter lets you choose a different separator.

print("2026", "10", "01", sep="-")
print("apple", "banana", "cherry", sep=", ")

Expected output:

2026-10-01
apple, banana, cherry

sep controls what goes between values; end controls what goes after the last value.

Common Mistakes

MistakeExampleResult
Missing quotes around textprint(Hello)NameError
Mismatched quotesprint("Hello')SyntaxError
Joining a string and a number with +print("Age: " + 25)TypeError
Using a capital letterPrint("Hi")NameError — Python is case-sensitive
Using curly "smart" quotes copied from a documentprint(“Hi”)SyntaxError: invalid character

Best Practices

  • Use commas or f-strings to combine text with other values.
  • Use one quote style consistently throughout your code.
  • Use print() freely while learning and debugging to see what your program is doing.
  • Python Comments — documenting your code
  • Python Variables — storing values to print later
  • Python String Formatting — f-strings and the format() method

0 Comments

Reviewed before they appear

No comments yet.

Python
Ask about this post
AI Ask about this post

Ask questions about Python Output Using print() and get answers drawn from it.

Signed-in readers only.