Comments

Comments

Comments are snippets of text in your code that the Python interpreter ignores. They’re useful for explaining code,
leaving notes, or temporarily disabling code.

Single-Line Comments

Use the # symbol to write a single-line comment.

# This is a single-line comment
print("Comments are ignored by the interpreter")

Example Use Case:

# Calculate the area of a circle
radius = 5
area = 3.14 * radius ** 2
print(f"The area is {area}")

Multi-Line Comments

While Python doesn’t have a specific syntax for multi-line comments, you can use triple-quoted strings ''' or """
that are not assigned to any variable.

"""
This is a multi-line comment.
It can span multiple lines.
Useful for longer explanations.
"""
print("Multi-line comments can be created using triple quotes.")

Alternative Method:

Use # at the beginning of each line.

# This is a multi-line comment
# Each line starts with a hash symbol
# This method is straightforward and clear