Comments in Python
Comments play a very important role in the maintenance of the program. It explicates what's actually happening inside a program. when we place comments inside the source code, it enhances the readability and understanding of the code.
Comments do not affect the execution speed and the size of the compiled program. Python Interpreter ignores the comment.
Python permits two types of comments, namely
- Single-line Comments
- Multi-line Comments
It begins with a hash (#) symbol and terminates at the end of the line.
# This is a single line comment # Adding two numbers (2 and 3) print(2+3)
If we want to put comments in more then one line we can use hash(#) beginning of every line.
# Hey folks # We can place the hash symbol in # beginning of the each line # To extends comments to multiple line
There is one more way to do the same, using triple quotes either ' ' ' or " " "
""" Here is the best example to write multi-line comments"""