Skip to content

This textbook is in beta – content is actively being refined. Report issues or suggestions

04.05 Debugging Tools And Techniques - Quiz

Check your understanding

  1. 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
  2. Which type of bug prevents code from running at all?

    • Logic errors
    • Runtime errors
    • Syntax errors { data-correct }
    • Performance errors
  3. 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
  4. 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
  5. What is the simplest debugging technique?

    • Using breakpoints
    • Adding print statements { data-correct }
    • Single line stepping
    • Using watches
  6. What is a breakpoint?

    • A syntax error in code
    • A marker that pauses program execution { data-correct }
    • A type of loop
    • A function parameter
  7. When debugging the factorial function, what should factorial(0) return?

    • 0
    • 1 { data-correct }
    • undefined
    • an error
  8. What debugging technique lets you monitor specific variables during execution?

    • Breakpoints
    • Watches { data-correct }
    • Print statements
    • Single stepping
  9. Which statement is used to check preconditions and postconditions in Python?

    • print()
    • if
    • assert { data-correct }
    • try
  10. 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
  11. 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
  12. 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