Sample questions
Python Institute Certified Professional in Python Programming 2 (PCPP2) (PCPP2) practice questions
Which keyword is used to raise an exception in Python?
When using SQLAlchemy Declarative Base, how do you define a table name that differs from the class name?
You need to ensure that a class can only be instantiated once throughout the application lifecycle. Which design pattern is most appropriate?
When using inheritance, how can you explicitly call a method from a specific parent class that is not the immediate superclass?
When writing a context manager using the @contextlib.contextmanager decorator, what should the function do to pass a value to the 'as' clause?
You need to ensure that a method can be called on the class directly, without requiring an instance. Which decorator should be used?
Which THREE of the following features are common to both the threading and multiprocessing modules?
Which THREE of the following are benefits of using __slots__?
Which TWO of the following are potential issues when using the 'fork' start method in multiprocessing?
Which command-line argument shows the values of local variables in the event of a test failure?
Which THREE of the following are valid address families or socket types used with the Python socket module?
You are designing a class hierarchy where a subclass needs to ensure it calls the constructor of its parent in a multiple inheritance scenario. Which mechanism is the standard Pyth…
You are handling large datasets and want to improve memory efficiency. Which Python feature allows you to iterate over a large sequence without loading it entirely into memory?
When using a multiprocessing.Queue to share data between processes, what happens if the queue is full and you use the put() method without a timeout?
Which TWO of the following are valid ways to execute a raw SQL query in SQLAlchemy?
You are utilizing abstract base classes (ABCs). How do you enforce that a subclass implements a specific method?
Which command-line tool is typically used to inspect the contents of a SQLite database file?
Which built-in function allows you to retrieve an attribute from an object by its string name?
You are using the multiprocessing.Process class and notice that child processes are not terminating cleanly. Which method should you call to ensure the main process waits for the c…
Two threads are modifying a shared global integer. You want to ensure that only one thread modifies the integer at a time. Which synchronization primitive is most appropriate?
When using the multiprocessing module, why is it recommended to use a Manager object instead of a standard dictionary to share data between processes?
Which PyMongo method should be used to update a single document if you want to modify specific fields without replacing the entire document?
You are writing a Python script that needs to perform heavy I/O-bound tasks concurrently. Which module should you prioritize to minimize the overhead of global interpreter lock (GI…
Which TWO of the following scenarios are best suited for the subprocess module?