Hello, Developer!
Today, we will learn the "Comments". Comments are not execute in program but it is really important to write comments in programs. Because comments make you easily understand codes, features and logic of program.
Comments Declaration and Examples
You can write comments in single line with starting "#" character. (i.e: # This is single line comment)
Also, you can start comments using "#" character in the command line.(i.e: print("This comment explanation line") # This is print out string
For multi-line comment, you can use " ''' " character at the start and end line.
(i.e: '''
This
is
multi
line
comments
''')
In the Python programming, "#" character is used for comment officially. So we recommend you to use "#" instead " ''' " multi-line comment command.
Comment also can be used to except codes from running while you're debugging or have code test. If you add "#" character where you want to exclude program running, starting "#" lines won't be run.
Here, I showed full exercise codes and running result as below.
# This program is cool
# This prints out a string
print("Comments are fun!")
'''
This multi-line comments
won't be run
Because
these lines
are
comments
print("This is comment")
'''
# print("Comment test message)
Can you see the same result? Congratulations! Now you can write comments in the Python program wherever you want.
Thank you for your reading this post and see you on next post, Python developer! 😊