Exercise: Python

Questions for: Debugging

What is the purpose of the Python input() function during debugging?
A:
Pauses the program execution and waits for user input
B:
Prints debugging information to the console
C:
Exits the program immediately
D:
Sets a breakpoint in the code
Answer: A
The input() function in Python pauses the program execution and waits for user input during debugging, allowing interaction with the program.
Which Python module allows you to set breakpoints and inspect variables interactively during program execution?
A:
sys
B:
trace
C:
debugger
D:
pdb
Answer: D
The pdb module in Python provides a built-in debugger that allows setting breakpoints and interactively inspecting variables during program execution.
What does the Python step command do in a debugger like pdb?
A:
Skips the current line of code
B:
Steps into a function or method call
C:
Exits the debugger
D:
Continues execution until the next breakpoint
Answer: B
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.
In Python, what does the sys.settrace() function do?
A:
Sets the system timezone for debugging purposes
B:
Enables trace functions for the entire system
C:
Sets a custom exception handler
D:
Sets a trace function for all thread events
Answer: D
The sys.settrace() function in Python sets a trace function for all thread events, allowing you to monitor and debug the execution flow.
Which Python module provides a graphical user interface (GUI) for interactive debugging?
A:
pdb
B:
debugger
C:
debugtools
D:
pydebug
Answer: A
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.
Ad Slot (Above Pagination)
Quiz