Python is
one of the easiest programming languages for beginners. One of the first things
every learner starts with is printing output and writing comments. This blog
will guide you step-by-step in a simple and clear way.
1. What
is a Print Statement in Python?
In Python, the print() function is used to display output on the screen.
Everything written inside the parentheses of print() will be shown on the
screen. This data may be in the form of text or may be integer or other special
symbols.
👉 Basic Syntax:
print("Hello World")
👉 Output:
Hello World
This is the
simplest way to show text, numbers, or results in Python.
📌 2. Printing a String (Text)
A string is anything written inside quotes ("" or
''). This shows that the statement inside the quotes is a string type. It is
also the syntax of writing a long or string statements in programming
languages.
👉 Example:
print("My name is Alice.")
print('I am learning Python')
👉 Output:
My name is Alice.
I am learning Python
✔️ You can use single quotes ' ' or
double quotes .
📌 3. Printing Numbers and Mixed Data
Python
allows you to print numbers and combine them with text. It means we can write
the text and numbers combined in one statement. Python and also other
programming languages allow us to write both of them together in one statement.
👉 Example:
print(25)
print("Age:", 25)
👉 Output:
25
Age: 25
📌 4. Printing on a Single Line
By default, Python prints each statement on a new line. But
you can change this behavior. Python allow us to change the things and
environment according to our needs and requirements. It we want to print two
statements in one line we use this method.
✅ Method 1: Using end=""
print("Hello", end=" ")
print("World")
👉 Output:
Hello World
✔️ The
end=" " tells Python not to go to the next line.
✅ Method 2: Using multiple values in
one print
This is
another method of writing statements in python.
print("Python",
"is", "fun")
👉 Output:
Python is fun
✅ Method 3: Using sep parameter
This type of parameter tells the compiler that the statements
inside the quotes is separated by a small slash.
Example:
print("2026", "04",
"29", sep="-")
👉 Output:
2026-04-29
📌 5. How to Write Comments in Python
Comments are
notes for better understanding, not executed by Python. They are written in the code to create easiness for debugging.
Sometimes we need to reread the code after a long time, in these types of
condition the comments are very useful. These are also useful in modular programming.
You can left messages behind for humans.
They help
explain your code.
✅ Single-Line Comment
Use # to add single line comment in python
# This is a comment
print("Hello Python")
✔️ Output:
Hello Python
Everything
after # is ignored.
✅ Multi-Line Comment
Python does not have a special multi-line comment, but we
use triple quotes.
Example:
Print(“Learning
Python”)
"""
This is a
multi-line comment
It can span
multiple lines
"""
Output:
print("Learning Python")
📌 6. Why Comments Are Important?
Comments
help you:
·
Understand your code later
·
Explain logic to others
·
Make debugging easier
Example:
# This program prints a greeting message
print("Welcome to Python
Programming")
📌 7. Summary
· print() → used
to display output
· Strings → text
inside quotes
· Single line
output → use end="" or multiple values
· Comments → use #
or triple quotes
🚀 Final Thought
Printing and
comments are the foundation of Python programming. Once you master them, you
can easily move toward variables, loops, and functions.


Comments
Post a Comment