In this article you will learn some basic topics of Python Comments.
Python Comments- Before moving ahead let’s know a little bit about Python.
Python Comments – One of the most useful functions of Python is Python comments which allows programmers to write comments while writing codes by using sign (Hash- (#)). In the starting of the line use sign (#) and write your line and it will be rendered or read as comment and not considered as code by Python. There’s no limit of comments in Python, as a programmer you can write as many you want.
Why should use comments in Python – A Comment in Python defined as writing a rough line of code or statement to make the code more readable and understable. In other words, Comments can be used to prevent execution while testing code.
Creating a Comment
# Hello programming world.
To define code or make it more readable, Comments can be used at the end of the line, but Python will not consider as Comment line.
print("Hello!") # It will not stop Python from executing code. print('codingstreets.') # It will not stop Python from executing code.
A comment is not mandatory to be text line, it can be itself a code in Python
#print('Hello World') print('This is not a comment') #print('This is a comment')
Multi Line Comments – Multi-line comments are defined as writing more than one line of statement.In Python, multi-lines comments can be written with two types, either adding sign (#) in starting of each line or write your statement inside Triple Quotes (“””).
Write multi-line comments by adding sign (#) in starting of each line.
# As a beginner I should learn Python. # I like to learn computer programs. # Hello programming world.
Write multi-line comments by placing statement inside Triple Quotes (“””).
If you find anything incorrect in above discussed topic and have any further question, please comment down below.
Follow us on