Making annotations within programs

A comment or annotation is a piece of text inside a program that has no effect on the program. Comments are used to make notes about the code itself for those reading it. A comment is made simply by writing some text after the # character:

# I'm a comment, I have no impact on the function of the program
# but provide useful information about the code.
# This code prints the words 'Hello World!' to the output...
print('Hello World!')

Annotations are useful for two reasons. First, annotations can help others understand what your code does and how it functions. However, even if you don't need to collaborate or share your work, annotations are very helpful in helping you mentally organize your own work. This is especially useful if you end up needing to reuse a piece of code weeks or months after writing it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset