Hey there! Welcome back to another post in the Python Basics Series.
If you’ve been following along, great job! If not, don’t worry — I’ve added a link to the playlist in the description so you can catch up before continuing.

Now, here’s a quick question:
What’s the very first thing every programmer does when learning a new language?
Yep — they print “Hello, World!” on the screen!
It’s like a rite of passage for programmers, and today, we’re diving into exactly that — the print() function in Python.

Whether you’re displaying messages, checking variables, or debugging your code, you’ll use print() all the time. So let’s break it down and understand it completely.

 

What is the print() Function in Python?

Think of the print() function as your program’s voice.
It doesn’t change any variables or perform calculations — it simply takes whatever you give it and shows it on the screen.

For example, here’s the classic Hello World program in Python:

print("Hello, World!")

That’s it! Just type print(), add your message in quotes, and Python will display it in your terminal.


Important Things to Remember

1. Always Use Parentheses in Python 3

In Python 3, parentheses are required when using print.
✅ Correct:

print("Hello, World!")

That’s it! Just type print(), add your message in quotes, and Python will display it in your terminal.


Important Things to Remember

1. Always Use Parentheses in Python 3

In Python 3, parentheses are required when using print.
✅ Correct:

print("Hello, World!")

❌ Incorrect:

print "Hello, World!"

The second one will throw an error, so always remember the parentheses!


2. Use Quotes for Text

When printing text, wrap your message in single ('') or double ("") quotes.
Both will work fine:

print("Python is fun!")
print('Learning Python is exciting!')

Quotes tell Python that what’s inside is text (a string), not code.


Printing Numbers in Python

Here’s an interesting question — do you need quotes when printing numbers?

Let’s test it:

print(45)
print("45")

Both will display 45, but there’s a difference:

  • print(45) → treats 45 as a number.

  • print("45") → treats 45 as a string (text).

So, remember:

  • Numbers: no quotes.

  • Text: use quotes.


Printing Variables

Let’s say you have a variable:

text = "Hello, World!"
print(text)

This will print the value stored inside the variable.
But if you accidentally use quotes around the variable name:

print("text")

Python will print the word “text” itself — not the variable’s value.
So remember:

  • print(text) → prints the value inside the variable.

  • print("text") → prints the literal word text.


Printing Multiple Items with Commas

You can print multiple values easily by separating them with commas. Python automatically adds spaces between them.

name = "John"
age = 25
print("Hello! My name is", name, "and I am", age, "years old.")

Output:

Hello! My name is John and I am 25 years old.

Simple, right? No need to mess around with the + operator to combine strings.

Avoid String Concatenation Confusion

If you use + between strings and numbers, Python will throw an error:

name = "John"
age = 25
print("Hello! My name is " + name + " and I am " + age + " years old.")

❌ This won’t work because age is a number.
✅ To fix it, convert it to a string:

print("Hello! My name is " + name + " and I am " + str(age) + " years old.")

But again — using commas is much easier!


Common Mistakes Beginners Make

Here are two common errors you should watch out for:

  1. Missing Parentheses

print "Hello"
# Will cause an error
  1. Using Quotes When Printing Variables

print("name")
# Prints the word name, not the variable

Using print() for Debugging

The print() function is also super useful for debugging your code — that is, checking what’s happening while your program runs.

Example:

name = input("Enter your name: ")
print("User's name is:", name)

If you type Lucky as input, the output will be:

User's name is: Lucky

This helps you confirm that your variable is storing the correct value.

Debugging is not just about fixing syntax errors — it’s also about verifying your logic.
print() helps you see what your code is doing step by step.


Conclusion

And that’s it! 🎉
You now know how to use the print() function in Python — one of the most essential tools for every programmer.

You’ve learned:

  • How to print text, numbers, and variables

  • How to print multiple items

  • Common mistakes to avoid

  • How to use print() for debugging

In the next part of this Python Basics series, we’ll explore how to combine input() and print() to create your very first interactive mini application. It’s going to be fun — trust me!

If you found this guide helpful, don’t forget to like, share, and follow for more Python tutorials.
Thanks for coding with me! 🐍💻