Studyfin Studyfin ✨ Sign up free

Comments & code documentation

Grade 5 · Coding · Free lesson

Hi there! I am Studyfin, and I am so excited to help you learn about coding today!

When we write code, we use a design process. This helps us plan, build, and test our ideas to solve everyday problems.

We use comments in our code to write notes in plain English. The computer completely skips these notes when running our program.

move_forward() # This makes the robot walk turn_right()

Comments are super helpful when our code uses loops or events. They explain exactly why we wrote that part of the code.

Repeat 10 times: play_sound() Explains the loop!
✏️ Worked example

Imagine you are building a program to water a garden every morning. Walk through using a design process to write your program and explain it clearly with comments.

  1. First, we plan. We define the everyday problem: the garden needs water when the sun rises.
  2. Next, we design the steps. We need an event for sunrise, a loop to water, and a stop condition.
  3. Then, we write the code blocks. We put a loop inside our sunrise event block.
  4. Now, we add comments. We write: '# Loop runs 5 times to water the roses slowly'.
  5. Finally, we test our code. The comments help us remember what each block does as we fix any bugs.
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons