Skip to content
Home » Blog » How to Comment in Python now in a Simplified Version

How to Comment in Python now in a Simplified Version

Use of Comment in Python

Comment in Python is not a part of the Code, rather it makes your code more readable. Comments are ignored by compilers and interpreters.

Depending on the purpose of your program, comments can serve as notes to yourself or reminders, or they can be written with the intention of other programmers being able to understand what your code is doing.

Comments are the useful information that the developers provide to make the reader understand the source code. It explains the logic or a part of it used in the code

It is ideal to comment in your code, which will save a lot of time when you refer it after a long time.

Comments are usually helpful to someone maintaining or enhancing your code when you are no longer around to answer questions about it. These are often cited as a useful programming convention that does not take part in the output of the program but improves the readability of the whole program.

In this article we will discuss how to create comment using python.

Comment in Python

The Syntax for Comment in Python

For creating a comment, you have to type # followed by the comment

#This is a comment

Since comments don’t execute, this code will not be updated.

Comments are in the source code for humans to read, not for computers to execute.

Some Examples for Comment in Python

HELLO : EXAMPLE 1

# Taking input

name = input("Name: ")


# Greating name with hello

print(f"Hello {name}")
Name: Patlow
Hello Patlow

CONDITION : EXAMPLE 2

#Taking an input
n = int(input("Number: "))


#Creating the Conditions 

if n>0:
    print("The Number is Positive")

elif n<0:
    print("The Number is Negative")

else:
    print("The Number is 0")
Number: -21
The Number is Negative

SQUARE : EXAMPLE 3

# Defining the function square

def square(x):
    return x*x


#Calling the function and printing it

print(square(4))
16

Conclusion

In today’s post, we’ve discussed Comments in Python, looked at its syntax and why to use them. We have also taken a look into 3 examples where we use the comments. If you are on your way to becoming a Pythonista, you might find our site really helpful. Hit this link for more python related posts
Check it out, it’s Simply the Best Code.

13 thoughts on “How to Comment in Python now in a Simplified Version”

  1. Hey there! It really helped me!! Thank you so much for posting this blog. If I had anymore python doubts, I’ll make sure I’ll come back to this site! Thanks once again 🙂

  2. Your blog is extremely helpful. It clears all the doubts related to Python comments. Love to read more content.
    Thanks for sharing

  3. I apologise, but, in my opinion, you commit an error. I suggest it to discuss. Write to me in PM, we will talk.

  4. This is an incredible assignment. I truly value your work! So exact and also professional. Thanks a lot for your effort. There was a small mistake, but overall I was satisfied. There was a minor error, however overall I was satisfied. Many thanks a great deal! Great creating many thanks it was clear as well as was composed.

  5. This is an outstanding project. I actually value your work! So accurate and also professional. Thank you so much for your effort. There was a small mistake, yet overall I was pleased. There was a minor error, yet overall I was pleased. Many thanks a great deal! Great writing thanks it was clear and also was created as the directions and also with good

  6. This is an impressive job. I actually appreciate your job! So accurate and professional. Thank you so much for your effort. There was a minor mistake, but overall I was pleased. There was a minor blunder, yet total I was satisfied. Many thanks a lot! Good creating thanks it was clear and was composed as the guidelines as well as with good Examination Help Online referral

Comments are closed.