Comments are code inside a Python script that is not executed or run by the machine. Comments are only used to mark or provide written explanations in the script.
Comments are commonly used to let others understand what the script does, or to remind the programmer themselves if they edit the script again someday.
To use comments you simply write a hash sign # followed by your comment or by using string literals opened and closed with """.
Below are examples of using comments in Python:
#This is a comment
# This writing will not be executed
#comments with hash sign can only be used
#for
#one
#line
"""
Writing comments more than one line is
by using triple double quotes and
closed with triple double quotes too
"""
print("Hello World") #this is also a comment
#print("Welcome")
# comments can contain special characters !@#$%^&\*(),./;'[]\
#print name
print("Budi")
#print number/integer
print(123)
When you run the script above, you will see output in the form of Hello World, Budi and 123, because the writing/comments written are not executed.
Nonton & Buat Short Drama AI Gratis
Platform Microdrama AI pertama di Indonesia. Nonton short drama gratis atau buat drama pendek sendiri dengan AI dalam hitungan menit, tanpa kru & kamera.
100% Gratis untuk dicoba. Bagian dari ekosistem MicroDrama Indonesia.