💬 Code Comment
5th Grade 💻 Coding
A comment is text inside your code that the computer skips. It’s written for people, to explain what the code does and why.
In Python, a comment starts with a hash sign: # calculate the score. Everything after the # on that line is ignored when the program runs. In JavaScript, a comment starts with two slashes (//), and in Scratch you can add a yellow sticky note next to blocks by right-clicking.
A good comment explains “why,” not just “what”: # wait one second so the player can read the message is better than # wait one second. Programmers also use comments while debugging: they turn a line into a comment to “switch it off” for a while without deleting it.
For example
# Level 2 starts herehelps you quickly find the right part of a long program.- Ethan came back to his project after a month, and the comments he had written saved him an hour of guessing.
- When you’re hunting for a bug, you can turn a suspicious line into a comment with
#and see if the problem goes away.
📌 Remember: A comment = a note for programmers. The computer doesn’t read it.
Quick quiz
What is a comment in code?
What symbol starts a comment in Python?
What should a good comment explain?