Computer Science
Grade 2
20 min
The Wrong Number
Identifying the incorrect number in a sequence.
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Define a 'bug' as a mistake in a set of instructions.
Identify a number that breaks a simple counting pattern.
Explain why a number is 'wrong' in a sequence.
Use a step-by-step method to find a bug.
Correct a 'wrong number' bug in a simple code block loop.
Describe debugging as 'finding and fixing bugs'.
Oh no! A robot is packing toys, but it put a banana in the toy car box! ππ How do we help the robot fix its mistake?
Today, we will be detectives! π΅οΈββοΈ We will learn how to find mistakes, called 'bugs', in our code. Finding and fixing bugs is called debugging!
Real-World Applications
Fixing a wrong ingredient in a cookie recipe πͺ
Finding a puzzle piece that is in the wrong spot π§©
Correcting a...
2
Key Concepts & Vocabulary
TermDefinitionExample
Bug πA bug is a mistake or an error in the code. It makes the computer do something wrong.Telling a robot to jump 3 times, but it jumps 5 times.
Debug π οΈDebugging is when we find the bug and fix it! We become bug detectives.Finding the wrong instruction and changing it so the robot jumps 3 times.
Code π»Code is a set of instructions we give to a computer. It's like a recipe for the computer to follow.A block that says 'Move Forward' is a piece of code.
Sequence β‘οΈA sequence is a list of things in a special order. Each thing follows the one before it.The numbers 1, 2, 3, 4, 5 are in a sequence.
Pattern β¨A pattern is something that repeats over and over. It helps us know what comes next.Apple π, Banana π, Apple π, Banana π... The pattern is one app...
3
Core Syntax & Patterns
The Pattern Detective Rule π΅οΈ
1. Find the pattern. 2. Check each item. 3. Find what's different.
Use this rule when you look at a list of numbers or items. Find the one that doesn't belong!
The Step-by-Step Rule πΎ
Read the code one block at a time. Watch what happens after each step.
Use this when your code is running. It helps you see exactly where the mistake happens.
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
Code: `Repeat 2 times: [Jump 3 spots]`. This makes a frog move 6 spots total. The frog needs to move 9 spots. How can you fix this by changing only ONE number?
A.Change `Repeat 2 times` to `Repeat 3 times`
B.Change `Jump 3 spots` to `Jump 4 spots`
C.Change `Repeat 2 times` to `Repeat 9 times`
D.It's impossible to fix by changing one number
Challenging
You want a robot to clap 4 times and stomp 4 times. Look at the code: `Loop A: Repeat 4 times: [Clap]`. `Loop B: Repeat 5 times: [Stomp]`. Which loop has the 'wrong number' bug?
A.Loop A has the bug
B.Loop B has the bug
C.Both loops have bugs
D.Neither loop has a bug
Challenging
A pattern should be: ππππ. The code is `Repeat 3 times: [Show Apple], [Show Banana]`. This makes ππππππ. What is the wrong number?
A.The number of apples
B.The number of bananas
C.The number 3 in the 'Repeat' block
D.The number of blocks inside the loop
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free