Comments
The first line in the code editor starts with the hash character, #
:
# Chapter 1: First Python Program
This is a comment line.
Comments are text you write among your code that are ignored by the computer when your program runs.
Their uses include allowing you to add annotations in your program to clarify the purpose of your code, or to disable a piece of code that you don't want to execute for now.
One-line comments start with #
. Everything to the right of the hash becomes "commented out".
Now, add #
to the beginning of line 2, like this:
# Chapter 1: First Python Program
# print('Hello, Buzz Coder!')
print()
print("Hello, CodeCraft!")
Click 'run' and you'll see the console result. The message Hello, Buzz Coder!
disappears because its print()
statement has been commented out, and the computer no longer reads it.
Notes:
The very first line of every CodeCraft file becomes the name of the file by default. You can see it shown at the file name box at the top right corner of your screen. Whenever you start a new file, it's a good idea to give it a name as a comment to indicate its content.