Comments in python
Comments are used to annotate codes, and they are not interpreted by Python. Comments in Python start with the hash character # and end at the end of the physical line in the code. A comment may appear at the start of a line or following whitespace or code, but not within a string literal. A hash character within a string literal is just a hash character. This type of comment is also known as a single-line comment.
The other way we can annotate code is by using a multi-line comment that serves as a reference or documentation for others to understand the code.
Let us have a look at the single-line comment in the following example.
# Following line used to declare the two integer numbers
num1 = 5
num2 = 8
We can write a comment after code line to annotate what particular line does as depicted in the following example.
sum = num1 + num2 # Add two literals num1 and num2
Python does not support multi-line/block comments. However, we can span comments across multiple lines using the same notation that we use for single line comments. Block comments are intended to the same level as that of code. Each line of a block comment starts with a # and a single space.