Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Your First Program · Lesson 6 of 11

Comments

A free lesson from Swipe Coding · Python, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Comments are the one part of your code Python never even looks at. 🐍

A comment is a note in your code that Python completely ignores when it runs. Comments exist purely for humans — to explain why a piece of code exists, or what a tricky line is actually doing — not for the interpreter.

# This calculates the discounted price
price = 100
discounted = price * 0.8  # apply a 20% discount
A # starts a comment that runs to the end of the line. Everything after it is ignored when the program runs.
🤖
One symbol, every time — refreshingly simple compared to some languages. 💬

Unlike Java's // and /* */, Python only has this one comment style. To comment out several lines in a row, you simply start each one with its own #.

# Step 1: read the input
# Step 2: validate it
# Step 3: process it
value = input()
Stacking # on consecutive lines is Python's way of writing a multi-line comment — there's no separate block-comment syntax.
Fill in the blank

In Python, a comment starts with the ____ symbol and runs to the end of the line.

Good comments explain the why, not the what. print("Hi") # prints Hi is a useless comment — the code already says that clearly. A comment earns its place when it explains a reason that isn't obvious from the code itself, like why a particular number or approach was chosen.

Quick check

What happens to a line of code that starts with #?

True or false

Python has a dedicated multi-line comment syntax, similar to /* */ in Java.

Chapter quiz

Your First Program

10 questions · pass with 60% — just like in the app.

Quick check

What must a Python file contain to be a complete, runnable program?

True or false

In Python, the interpreter executes a file's statements from top to bottom.

Fill in the blank

Python files conventionally use lowercase, underscore-separated names, a style called ____.

Quick check

Which function is used to display output in Python?

True or false

By default, print() places a single space between multiple comma-separated values.

Fill in the blank

The end keyword argument of print() defaults to a ____ character.

Quick check

What symbol starts a comment in Python?

True or false

Python has a dedicated multi-line comment syntax, similar to /* */ in Java.

Fill in the blank

To comment out several lines in a row, you start ____ of them with its own #.

Quick check

What does sep="-" do when passed to print("a", "b", "c", sep="-")?

Keep your streak going in Swipe Coding

Swipe through every level of Python on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →