Python Programming - Debugging

Exercise : Debugging - General Questions
  • Debugging - General Questions
16.
What does the Python pdb.run() function do?
Executes the Python script without any debugging
Launches an external debugger for the entire script
Runs the Python script with an embedded debugger
Terminates the program immediately
Answer: Option
Explanation:
The pdb.run() function in Python runs the Python script with an embedded debugger, allowing for interactive debugging.

17.
What does the Python inspect module provide in terms of debugging?
A way to insert breakpoints in the code
Information about the call stack and code introspection
A graphical user interface for debugging
A custom exception handler
Answer: Option
Explanation:
The inspect module in Python provides information about the call stack and code introspection, aiding in debugging.

18.
What does the Python set_trace() function do in the pdb module?
Exits the program immediately
Inserts a breakpoint in the code for debugging
Prints debugging information to the console
Skips the next loop iteration
Answer: Option
Explanation:
The set_trace() function in the pdb module is used to insert a breakpoint in the code for debugging, allowing interactive debugging at that point.

19.
What is the purpose of the Python traceback.format_exc() function?
Terminates the program immediately
Prints debugging information to the console
Formats the exception traceback as a string
Inserts a breakpoint in the code
Answer: Option
Explanation:
The traceback.format_exc() function in Python formats the exception traceback as a string during debugging.

20.
What is the purpose of the Python pdb.post_mortem() function?
Exits the program immediately
Creates a post-mortem debugger session after an unhandled exception
Steps into a function or method call
Inserts a breakpoint in the code
Answer: Option
Explanation:
The pdb.post_mortem() function is used to create a post-mortem debugger session after an unhandled exception, allowing examination of the program state at the point of the exception.