Python Institute PCPP2 sample questions with explanations, traps, topic labels, and IT Mastery route links.
These original sample questions are designed to help you check how the exam topics appear in decision-style prompts. They are not taken from the live exam.
Use these sample questions as a guided self-assessment for Certified Professional Python Programmer 2 (PCPP2) topics such as advanced Python design, concurrency choices, serialization, networking boundaries, performance, testing, packaging, and production-quality maintainability. The prompts focus on architecture and operational trade-offs in Python systems.
The sample set below is part of the Python Institute PCPP2 guide path:
Work through each prompt before opening the explanation. PCPP2 questions tend to reward system-level reasoning: safe concurrency, clear interfaces, testable boundaries, and performance choices backed by measurement.
Topic: Choosing concurrency for I/O
A Python service must call 100 independent HTTP APIs and combine their responses. Each call spends most of its time waiting on network I/O. CPU use is low. Which design is usually the best starting point?
Best answer: A
Explanation: Network calls are I/O-bound, so overlapping waits can improve throughput. The important professional detail is bounding concurrency and handling timeouts or failures, not simply creating unlimited work.
Why the other choices are weaker:
What this tests: I/O-bound concurrency, bounded work, async or worker-pool design, and practical performance reasoning.
Related topics: Async I/O; Threads; Worker pools; HTTP clients; Timeouts
Topic: Safe serialization format
A service receives user-submitted data over an API. The data contains simple nested structures: strings, numbers, lists, and dictionaries. The service must parse the payload safely. Which format and approach is strongest?
pickle from clients because it preserves arbitrary Python objects.eval() on the request body because the payload resembles Python literals.Best answer: C
Explanation: JSON is appropriate for simple cross-system data structures, and schema validation checks that the decoded data matches what the service expects. Arbitrary object deserialization or code evaluation is unsafe for user-submitted payloads.
Why the other choices are weaker:
What this tests: Serialization boundaries, untrusted input, schema validation, and secure API design.
Related topics: JSON; Serialization; Validation; Security; API payloads
Topic: Testing external dependencies
A function sends a request to a payment provider. Unit tests should verify retry and error-handling behavior without making real network calls or charging accounts. What is the strongest testing approach?
Best answer: B
Explanation: A test double lets unit tests control external behavior and verify how the code reacts to success, timeouts, and errors. Real provider integration can be tested separately with controlled credentials and environment boundaries.
Why the other choices are weaker:
What this tests: Test isolation, mocks or fakes, external-service boundaries, and deterministic error handling.
Related topics: Unit testing; Mocking; Test doubles; External APIs; Retry logic
Topic: Performance investigation
A Python data-processing job became slower after a refactor. The team suspects a nested loop is expensive, but they are not sure. What should they do first?
Best answer: D
Explanation: Professional performance work starts with measurement. Profiling representative input identifies where time is actually spent. The right optimization may be an algorithm change, a data-structure change, batching, caching, or a targeted implementation improvement.
Why the other choices are weaker:
What this tests: Profiling discipline, representative workloads, algorithmic thinking, and avoiding premature optimization.
Related topics: Profiling; Performance; Algorithms; Refactoring; Optimization
Tech Exam Lexicon and IT Mastery are independent study tools. They are not affiliated with, endorsed by, or sponsored by Python Institute or any certification body.