Bugs: Find Them, Fix Them!
Bit's robot show went wrong! Can you find the bug?
Real Python code
This is the code from the video. Read it out loud like a recipe, one line at a time!
keys = 1
if keys == 0:
print("The door opens!")
else:
print("I need a key!")
Quiz time!
Bit wants to clap 3 times. Where's the bug?
for i in range(2):
print("Clap!")
Three sneaky bugs
Wrong order
The steps are in a mixed-up order
Wrong count
A loop repeats too many or too few times
Wrong check
An if asks the wrong question
Bugs are normal
Every coder makes them, every day
Be a bug hunter
Bug panic
- Change lots at once
- Guess and hope
- Give up
Bug hunter
- Read it slowly
- Expected vs happened
- Fix one, test again
Bugs are clues, not failures!
Try it yourself!
Build a tiny Scratch program with a bug in it on purpose, then ask a friend or family member to find it and fix it.
Bit is working on the next one: Functions: make your own blocks