Skip to content

Comments: Leaving Notes in Your Code

Beginning of the lesson

Comments: Leaving Notes in Your Code

Little notes the computer ignores, but people read

Big Idea: A comment is a note you write inside your code for people to read. The computer skips right over it — it does not run comments at all. Comments help you and other people understand what the code does and, even more importantly, why.
By the end you will be able to:
  • say what a comment is in simple words,
  • explain why the computer ignores comments but people read them,
  • give good reasons to leave notes in your code.

1. What is a comment?

Code is full of instructions — steps the computer follows. But a program can also hold a special kind of line called a comment. A comment is a note for humans. The computer treats it like it is invisible: it reads past it and runs only the real instructions.

You mark a comment with a special sign so the computer knows to skip it. In many languages that sign is // or # at the start of the note. You do not need to memorise the signs yet — the important idea is simple: a comment is a note the computer ignores and people read.

Think of a comment as a whisper to the reader that the computer cannot hear.

2. Why leave notes in your code?

Comments do not make the program run faster or do anything new. So why write them? Because code is read by people, not just computers. Good notes help in many ways:

  • Explain the "why". The code shows what happens; a comment can say why you did it that way.
  • Help future-you. When you come back weeks later, a note reminds you what you were thinking.
  • Help teammates. Other people can read your note and understand your code faster.
  • Leave reminders. A short "TODO" note can remind you to finish something later.
  • Turn code off for a moment. You can turn a line into a comment to hide it while you test — without deleting it.

Leaving clear notes is part of being a kind, careful coder. It is a gift to the next person who reads your code — and that person is often you!

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers