04.05 Debugging Tools And Techniques - Quiz¶
Check your understanding
-
What is debugging?
- Removing comments from code
- Optimizing code for better performance
- Finding and fixing errors in code { data-correct }
- Compiling code to machine language
-
Which type of bug prevents code from running at all?
- Logic errors
- Runtime errors
- Syntax errors { data-correct }
- Performance errors
-
What happens when a runtime error occurs?
- The code won’t compile
- The code runs but crashes during execution { data-correct }
- The code produces incorrect results
- The code runs slowly
-
In the factorial
range(n)?debugging activity, what was wrong with- It included zero in the multiplication { data-correct }
- It was too slow
- It used too much memory
- It caused a syntax error
-
What is the simplest debugging technique?
- Using breakpoints
- Adding print statements { data-correct }
- Single line stepping
- Using watches
-
What is a breakpoint?
- A syntax error in code
- A marker that pauses program execution { data-correct }
- A type of loop
- A function parameter
-
When debugging the factorial function, what should factorial(0) return?
- 0
- 1 { data-correct }
- undefined
- an error
-
What debugging technique lets you monitor specific variables during execution?
- Breakpoints
- Watches { data-correct }
- Print statements
- Single stepping
-
Which statement is used to check preconditions and postconditions in Python?
- print()
- if
- assert { data-correct }
- try
-
What is “single line stepping”?
- Writing code one line at a time
- Executing code one line at a time { data-correct }
- Deleting code one line at a time
- Commenting code one line at a time
-
In the buggy factorial function, why did factorial(1) return 0?
- The function was called incorrectly
- range(1) produces [0], so 1 × 0 = 0 { data-correct }
- There was a division by zero
- The variable wasn’t initialized
-
What should you do FIRST when debugging?
- Fix the code immediately
- Ask someone else for help
- Reproduce the bug consistently { data-correct }
- Rewrite the entire function