Comments make your program easier to understand. When you look back at your code or others want to collaborate with you, they can read your comments and easily figure out what your code does.
The # sign is for comments. A comment is a line of text that Python won't try to run as code. It's just for humans to read.
Write a comment on line 1. Make sure it starts with #. It can say anything you like. The result when running a comment on the interpeter must be the following one:
[email protected]:~# touch Comment.py [email protected]:~# echo ' #This is a comment (readonly)' > Comment.py [email protected]:~# [email protected]:~# [email protected]:~# python Comment.py [email protected]:~#
The # sign will only comment out a single line. While you could write a multi-line comment, starting each line with #, that can be a pain.
Instead, for multi-line comments, you can include the whole block in a set of triple quotation marks:
"""This is a paragraph containing readonly comments"""