In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters. Python Comments
There are two types of comment lines in python
- Single line comment
- Multi-line comments
1.Single line comment :
To comment a single line ,we use single line comment i.e. hash tag (#).
a = 5 # This is single line comment
print(a)
# output should be 5
5
Note: Comments are ignored by the interpreter during the execution of the program.
2.Multi-line comments:
To comment multiple lines, we use multi-line comment ,we write the text (comments) in triple double quotes (“““ ”””)or triple single quotes(‘’’ ’’’).
#This is
#Multi-line
#comment
print("Hello World!")
Hello World
Example 2:
"""
This is
Multi-line
Comment
"""
print("Hello World!")
Hello World
Advantages :
- Easy to understand.
- Code Readability.
- Explanation of the code or project.
- comment is a programmer-readable explanation or annotation in the source code of a computer program.
- There are two types of comment lines in python
- Single line comment
- Multi-line comments