When programming in python, comments can be used to explain your code.
Programmers use comments to make their code more readable.
If you want to make a comment, use # followed by the comment you want to make. Python will not execute your comment, that is, anything typed after a # is ignored by the language.
For Example:
#This is how you make a comment
#Printing "Hello World!"
print("Hello World!")
To make multiline comments, you need to insert a # for every new line. For example:
#This is line 1
#This is line 2
#This is line 3
Comments are not always used to explain code, it can also be used to prevent python from executing a piece of code. This helps with debugging your code. In the example below, the first line is not executed whereas the second line is executed:
#print("Hide this line")
print("Show this line")
Once you have completed reading this section, test your knowledge with a gamified quiz!