Python Programming - Debugging

Exercise : Debugging - General Questions
  • Debugging - General Questions
11.
What does the Python locals() function provide during debugging?
A list of all global variables
A dictionary of all local variables in the current scope
Information about the call stack
A list of all imported modules
Answer: Option
Explanation:
The locals() function in Python provides a dictionary of all local variables in the current scope during debugging.

12.
In Python, what does the breakpoint() function do?
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 breakpoint() function is used to insert a breakpoint in the code for debugging, allowing interactive debugging at that point.

13.
What does the Python globals() function provide during debugging?
A list of all global variables
A dictionary of all local variables in the current scope
Information about the call stack
A list of all imported modules
Answer: Option
Explanation:
The globals() function in Python provides a dictionary of all global variables during debugging.

14.
What is the purpose of the pdb.set_trace() function in the pdb module?
To insert a breakpoint in the code for debugging
To terminate the program immediately
To print debugging information to the console
To skip the next loop iteration
Answer: Option
Explanation:
The pdb.set_trace() function in the pdb module is used to insert a breakpoint in the code for debugging, allowing interactive debugging at that point.

15.
What does the Python traceback.print_exc() function do?
Terminates the program immediately
Prints debugging information to the console
Inserts a breakpoint in the code
Prints the exception traceback to the console
Answer: Option
Explanation:
The traceback.print_exc() function in Python is used to print the exception traceback to the console during debugging.