🐛
الدرس 15 · صف P3
Debugging: think like a detective
📖 الدرس
──▶
🎯 اختبار — اختر الترجمة
──▶
✅ أُنجز الدرس
A bug is a mistake in code, debugging is the hunt. Fact: 50% of programming is finding bugs. An error is not failure — it's a clue! "line 5: name is not defined".
- ●Read the error — it gives LINE and TYPE
- ●NameError: typo in variable name
- ●SyntaxError: bracket/colon forgotten
- ●Logic error: runs but wrong → print() everywhere!
Rubber-duck debugging: explain the code out loud — "here I add, here I check…". While explaining you find the bug yourself! Or halve it: comment out half — works? Bug is in the other half.
💡 The first "bug" was real: in 1947 a moth flew into the Harvard Mark II. They taped it in the logbook: "first actual case of bug being found"!