Comments¶
- As programs get bigger and more complicated, they get more difficult to read.
- For this reason, it is a good idea to add notes to your programs to explain in natural language what the program is doing.
- A comment in a computer program is text that is intended only for the human reader — it is completely ignored by the interpreter.
- Blank lines are also ignored by the interpreter.
In Python, the # token starts a comment. The rest of the line is ignored.
Here is a new version of Hello, World!.
1
#---------------------------------------------------
2
# This demo program shows off how elegant Python is!
3
# Written by Joe Soap, December 2010.
4
# Anyone may freely copy or modify this program.
5
#---------------------------------------------------
6
7
print("Hello, World!") # Isn't this easy!
8
(ch01_3)
Note
This workspace is provided for your convenience. You can use this activecode window to try out anything you like.
3
1
2
3
(scratch_01)