Python Programming - Debugging

Exercise : Debugging - General Questions
  • Debugging - General Questions
1.
What is the purpose of the Python pdb module?
To perform database operations
To debug and interactively explore code
To parse and manipulate XML data
To handle exceptions
Answer: Option
Explanation:
The pdb module in Python is used for debugging and interactively exploring code, providing a powerful debugger with features like breakpoints and code stepping.

2.
Which Python module provides a graphical user interface (GUI) for interactive debugging?
pdb
debugger
debugtools
pydebug
Answer: Option
Explanation:
The pdb module in Python provides a command-line interface for debugging. There is no built-in graphical debugger, but external tools like pdb++ can provide a graphical user interface.

3.
In Python, what does the sys.settrace() function do?
Sets the system timezone for debugging purposes
Enables trace functions for the entire system
Sets a custom exception handler
Sets a trace function for all thread events
Answer: Option
Explanation:
The sys.settrace() function in Python sets a trace function for all thread events, allowing you to monitor and debug the execution flow.

4.
What does the Python step command do in a debugger like pdb?
Skips the current line of code
Steps into a function or method call
Exits the debugger
Continues execution until the next breakpoint
Answer: Option
Explanation:
In a debugger like pdb, the step command is used to step into a function or method call, allowing you to debug the code inside that function.

5.
Which Python module allows you to set breakpoints and inspect variables interactively during program execution?
sys
trace
debugger
pdb
Answer: Option
Explanation:
The pdb module in Python provides a built-in debugger that allows setting breakpoints and interactively inspecting variables during program execution.