Home›Lesson Plans›Computer Science›Programming · Grades 3–5

Debugging: Finding & Fixing the Bug

Students learn that even great coders make mistakes — called bugs — and that debugging is the fun detective work of finding the one broken step and fixing it.

Grades 3–5Debugging45 minutes1 class periodCode LessonExplicit teaching4 StandardsISTE + CSTA
Start the Lesson
Lesson at a Glance

Everything you need before the bell rings

Learning Objectives

Students will be able to…

  • ✓Explain that a bug is a mistake in a program.
  • ✓Find the bug in a short program.
  • ✓Fix the bug so the program works.
  • ✓Explain that debugging is a normal part of coding.
Essential Question

Your program doesn’t work — but the computer isn’t “wrong,” it did exactly what you said. So how do you find the one step that’s off?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Find the Bug · Interactive

Find the Bug

Project each buggy program and read it aloud. Have students find the one command that’s wrong — the tool explains how to fix it.

🐛 Read the program — find the bugTry it
Which part is the bug?
The Lesson · Use · Modify · Create

45 minutes, five moves

Tap any phase to open the teacher moves and student actions.

1

Warm-Up — It’s Not Working!

5 min

A program runs but does the wrong thing — whose “fault” is it?

👩‍🏫 Teacher Moves

  • Show a program that misbehaves.
  • Explain the computer did exactly what was written.
  • Set the goal: debugging.

🎒 Student Actions

  • Watch it go wrong.
  • Realize the steps are off.
  • Predict what “bug” means.
2

Learn — Bugs Are Normal

10 min

Teacher models debugging.

👩‍🏫 Teacher Moves

  • Define bug and debug.
  • Model reading a program step by step.
  • Find and fix one bug aloud.

🎒 Student Actions

  • Learn bug vs. debug.
  • Follow the step-by-step check.
  • See a fix.
3

Use It — Find the Bug

12 min

Students use the tool.

👩‍🏫 Teacher Moves

  • Work through the buggy programs.
  • Have students find the bug first.
  • Explain the fix each time.

🎒 Student Actions

  • Find each bug.
  • Explain the fix.
  • Check the reasoning.
4

Create — Debug a Program

13 min

Students create/fix.

👩‍🏫 Teacher Moves

  • Give buggy programs (or grid robot).
  • Have students find and fix the bug.
  • Then break and swap with a partner.

🎒 Student Actions

  • Fix a buggy program.
  • Test the fix.
  • Debug a partner’s.
5

Share — Share

5 min

Students share a fix.

👩‍🏫 Teacher Moves

  • Invite a bug-and-fix story.
  • Normalize mistakes as learning.
  • Hand out the exit ticket.

🎒 Student Actions

  • Share a bug and fix.
  • Explain the check they used.
  • Complete the exit ticket.
Standards Alignment

Built to the standards you report on

Aligned to the ISTE Standards for Students and the CSTA K-12 Computer Science Standards.

CSTA
1A-AP-14

Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops.

CSTA
1B-AP-15

Test and debug a program or algorithm to ensure it runs as intended.

ISTE
Computational Thinker

Test solutions and troubleshoot to improve them.

CCSS
RI.3.3

Describe steps in a procedure using sequence language.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Highlight the buggy step in color.
  • Sentence frame: “The bug is ___. It should be ___.”
  • Walk a buggy path to see the error.

Support & Access

IEP / 504
  • Give programs with one obvious bug.
  • Offer two choices instead of three.
  • Fix one step at a time and re-run.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Find and fix two bugs in one program.
  • Explain why the computer isn’t “wrong.”
  • Write a buggy program for a friend to fix.
Materials

What to gather

  • 📽️Projector / board
  • 📓Notebooks
  • 💻Find the Bug
  • 🔍Buggy-program cards
  • ✏️Pencils
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

buga mistake in a programdebugto find and fix a bugerrorsomething that went wrongtestto run and check a programfixto correct a mistakeprograma sequence of commandstraceto follow a program step by steppersevereto keep trying when it’s hard
Evaluate

Exit Ticket

Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.

QUESTION 1
What is a “bug” in coding?
A mistake in a program that makes it do the wrong thing.
QUESTION 2
A program should go UP, UP but says UP, DOWN. What is the bug and the fix?
The bug is DOWN; change it to UP so the program goes UP, UP.
QUESTION 3
Is it bad to have bugs in your code? Why or why not?
No — all coders get bugs. Finding and fixing them (debugging) is a normal, important part of coding.

Going deeper? Bug swap.

Have students write a working program, add one bug on purpose, then trade and race to find each other’s bug. A printable bug-swap card is in the CS library.

Study · Flashcards

Study the key terms

Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.

🃏 DebuggingFlip
Card 1
Term
Tap to flip →
Meaning
0

Nice work!

Practice · Quiz

Check your understanding

A quick self-check with instant feedback, drawn from this lesson’s key terms.

📝 DebuggingQuiz
Score: 0
1 / 6
Question 1
0%

Nice work!

Practice · Worksheet

Printable worksheet

A print-and-go review sheet with a built-in answer key. Tap “Show answer key” to reveal answers, or print the clean version for students.

🖨️ DebuggingPrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: bug, debug, error, fix, persevere, program, test, trace
  1. to correct a mistake
  2. to keep trying when it’s hard
  3. to run and check a program
  4. to follow a program step by step
  5. a sequence of commands
  6. a mistake in a program
  7. something that went wrong
  8. to find and fix a bug

Part B · Show what you learned

  1. What is a “bug” in coding?
  2. A program should go UP, UP but says UP, DOWN. What is the bug and the fix?
  3. Is it bad to have bugs in your code? Why or why not?
Answer key — Part A: 1) fix · 2) persevere · 3) test · 4) trace · 5) program · 6) bug · 7) error · 8) debug
Part B: 1) A mistake in a program that makes it do the wrong thing. 2) The bug is DOWN; change it to UP so the program goes UP, UP. 3) No — all coders get bugs. Finding and fixing them (debugging) is a normal, important part of coding.