menu

Python Testing and Debugging


1. What is code coverage in Python testing?

The percentage of code that is executed during testing

The amount of time it takes to run a test suite

The number of test cases that are run during testing

The number of bugs that are found during testing


2. What is a breakpoint in Python debugging?

A point in the code where execution is paused to allow for inspection

A point in the code where execution is terminated

A point in the code where a specific action is triggered

A point in the code where an error is expected to occur


3. What is a breakpoint in Python?

A location in the code where the program stops running

A location in the code where the program starts running

A location in the code where the program outputs a message

A location in the code where the program skips a line


4. Which tool in Python can be used for profiling and optimizing code performance?

cProfile

timeit

memory_profiler

all of the above


5. Which tool is used for profiling Python code?

cProfile

unittest

logging

pdb


6. What is an assertion in Python testing?

A statement that tests whether a condition is true

A statement that generates a warning message

A statement that terminates program execution

A statement that logs a message to a file


7. Which module in Python provides support for unit testing?

unittest

pytest

doctest

all of the above


8. What is a mock object in Python?

An object that simulates the behavior of a real object

An object that replaces a real object in a test

An object that verifies the behavior of a real object

An object that tests user interface interactions


9. What is a runtime error in Python?

An error that occurs when the code is not valid Python syntax

An error that occurs when the program runs out of memory

An error that occurs when the program encounters unexpected input

An error that occurs during program execution, such as dividing by zero or accessing an undefined variable


10. What is the purpose of a debugger in Python?

To help identify and fix errors in code

To optimize code performance

To test user interface interactions

To generate documentation for code