PyPyPath

Module 2: Python Basic Syntax and Data Types

Comments

Comments are notes for humans. Python ignores them — they help you remember what your code does.

About 5 minutes

Single-line comments

Start a comment with the # symbol. Everything after # on that line is ignored.

Example code
# This is a comment — Python skips it
print("This runs")  # comment at end of line

Multi-line comments (doc style)

For longer notes, you can use triple quotes """ ... """ as a string that you don't assign to anything — Python still runs fine.

Example code
"""
This explains the program below.
We print a welcome message.
"""
print("Welcome!")
What Python sees

You write

Code + comments

Python runs

Only real code

Good comments explain WHY, not obvious things. Example: # Convert age to days for chart

Practice

Add a comment above each print line explaining what it does.

Key takeaways

  • # starts a single-line comment.
  • Comments are for humans; Python ignores them.
  • Use comments to explain tricky parts of your code.

Quick check: Comments

Question 1 of 2

How do you start a single-line comment in Python?