Python comments:
In programming, comments are like detailed notes that you strategically add to explain parts of your code. They make it easier for other programmers to understand when they check out your code. Comments are also really helpful for the person who wrote the code in the first place.
According to Wikipedia, 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.
Single line comments:
For short and easy-to-understand lines of code, you can simply put a # right before that line. In the example below, notice that the comment (informing that import library) is in a different color (e.g: green). This means the program will ignore these comments, and they won’t affect how the code runs.
Inline comments:
Inline comments are brief explanations or annotations that are inserted within the code to provide information about specific lines or sections of python code. These comments are considered for human readers and are ignored by the Python interpreter during execution. Inline comments in Python are created using the # symbol. Everything to the right of the # symbol on the same line is considered a comment . In the example below, comment (informing that it is list ) is in green color which will ignored by interpreter but it will give information to reader.
Multiple line comments:
There is no specific syntax for multiple-line comments in Python. So, to write multiple line comments you can use triple-quoted strings (single ”’ ”’ or double quotes “”” “””) or you can use # before each line of comments.
Writing multiple comments using”’ ”’&“”” “””
Writing multiple comments using#