PCPP-1 Certified Professional Python Programmer Level 1 Practice Exam Q&A, Exams of Computer Science

Practice exam questions and answers for the pcpp-1 certified professional python programmer level 1 certification. It includes verified answers and rationales for each question, making it a valuable resource for exam preparation. The questions cover a range of python topics, including modules, context managers, exceptions, descriptors, iterators, metaclasses, threading, file i/o, and more. This q&a is designed to help candidates test their knowledge and understanding of python programming concepts and prepare for the certification exam. It is updated for the 2025/2026 syllabus.

Typology: Exams

2025/2026

Available from 12/16/2025

lewis-nyaga-muriithi
lewis-nyaga-muriithi 🇺🇸

2.2K documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PCPP-1 (Certified Professional Python
Programmer Level 1) Practice Exam Questions
And Correct Answers (Verified Answers) Plus
Rationales 2025/2026 Q&A | Instant Download
Pdf
1. Which Python module provides the Enum base class for creating
enumerations?
A. types
B. collections
C. enum
D. itertools
The enum module defines the Enum base class.
2. What is the purpose of a context manager in Python?
A. To schedule asynchronous tasks
B. To manage setup and teardown actions using __enter__ and
__exit__
C. To define thread-local storage
D. To handle recursion limits
Context managers wrap operations requiring deterministic cleanup.
3. Which statement correctly defines a custom exception?
A. class MyErr(ExceptionError): pass
B. class MyErr(Exception): pass
C. class MyErr(BaseError): pass
D. raise MyErr
Custom exceptions inherit from Exception.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download PCPP-1 Certified Professional Python Programmer Level 1 Practice Exam Q&A and more Exams Computer Science in PDF only on Docsity!

PCPP-1 (Certified Professional Python

Programmer Level 1) Practice Exam Questions

And Correct Answers (Verified Answers) Plus

Rationales 2025/2026 Q&A | Instant Download

Pdf

1. Which Python module provides the Enum base class for creating enumerations? A. types B. collections C. enum D. itertools The enum module defines the Enum base class. 2. What is the purpose of a context manager in Python? A. To schedule asynchronous tasks B. To manage setup and teardown actions using enter and exit C. To define thread-local storage D. To handle recursion limits Context managers wrap operations requiring deterministic cleanup. 3. Which statement correctly defines a custom exception? A. class MyErr(ExceptionError): pass B. class MyErr(Exception): pass C. class MyErr(BaseError): pass D. raise MyErr Custom exceptions inherit from Exception.

4. Which of the following is true about descriptors? A. Descriptors only work with class methods B. Descriptors are created using decorators C. Descriptors define get, set, or delete D. Descriptors replace metaclasses Descriptors manage attribute access. 5. Which method is required to make an object iterable? A. getitem B. iter C. next D. call Iterable objects implement iter returning an iterator. 6. What is the output of sorted({3,1,2})? A. {1,2,3} B. (1,2,3) C. [1,2,3] D. {3,1,2} sorted() returns a list. 7. What Python feature allows modifying class behavior during creation? A. Decorators B. MRO C. Metaclasses D. Dict comprehensions Metaclasses customize class construction.

12. What does functools.lru_cache() provide? A. Parallel processing B. Memoization of function results C. Logging of return values D. Thread-safe caching LRU cache stores recent calls. 13. Which operator triggers the descriptor protocol? A. is B. in C. Attribute access (obj.attr) D. == Attribute access invokes descriptors. 14. In Python packaging, which file lists dependencies? A. MANIFEST.in B. pyproject.toml C. README.md D. setup.cfg only PEP 621 recommends defining dependencies in pyproject.toml. 15. Which keyword makes an abstract method? A. staticmethod B. @abstractmethod C. @abstract D. @required Defined in abc module.

16. Which type of inheritance can cause the diamond problem? A. Single B. Multilevel C. Multiple D. Hierarchical Multiple inheritance creates ambiguity. 17. What is ensured by using a with statement for files? A. Data compression B. Increased speed C. Automatic file closure D. OS-level locking Context managers guarantee cleanup. 18. What does inspect.signature(func) return? A. Source code B. Function name C. Function parameters specification D. Closure vars inspect.signature returns a Signature object. 19. A dataclass generates all except which? A. init B. repr C. getattr D. eq Dataclasses do not create dynamic attribute handlers.

23. Which built-in function copies an iterator's items into a list? A. copy B. slice C. list() D. iter() list(iterator) materializes items. 24. What does slots do? A. Creates thread-safe objects B. Makes objects immutable C. Restricts attribute creation to reduce memory D. Controls MRO Prevents dynamic attribute dict. 25. What is the output? a = [ 1 , 2 , 3 ] b = a b.append( 4 ) print(a) A. [1,2,3] B. Error C. [1,2] D. [1,2,3,4] Lists are mutable and referenced. 26. Which library provides advanced regular expression support?

A. builtin_re B. rdex C. re D. pattern Python’s regex library is re.

27. Which operation is atomic in CPython? A. List append B. File write C. Incrementing integer in a single bytecode D. Opening a socket Some simple bytecode ops are atomic under GIL. 28. What does dataclasses.field(default_factory=list) do? A. Creates a shared list B. Creates a new list per instance C. Creates static attribute D. Prevents mutation Default factory avoids mutable default traps. 29. Which idiom checks if a module is run as main? A. if run == "main": B. if script: C. if name == "main": D. if main: print() Standard main-guard. 30. Which method is called when an object is used as a context manager?

A. property = lambda x: x B. def prop(): pass C. @property decorator D. class property: pass @property converts a method to managed attribute.

35. How do you run code asynchronously? A. run async() B. Using async and await keywords C. Using only threads D. Using only processes async/await creates coroutines. 36. What is marshaling in Python? A. Running a server B. Converting objects to byte streams C. Creating modules D. Interpreting bytecode Serialization technique. 37. Which is not a valid JSON type? A. string B. array C. object D. tuple JSON has no tuple type. 38. Which method initializes a dataclass post-construction?

A. start B. begin C. post_init D. after Runs after dataclass init.

39. What does weakref allow? A. Faster reference counting B. References that don't increase refcount C. Immutable pointers D. Cyclic GC disabling Weak references prevent memory leaks. 40. Which module supports event-driven async operations? A. concurrent B. threading C. asyncio D. selectors asyncio provides event loop. 41. What is the default pickle protocol in modern Python versions? A. 1 B. 2 C. 3 D. 5 Protocol 5 introduced in Python 3.8 and is default in many builds. 42. What is a closure?

A. They replace the OS B. They compile bytecode C. They isolate package installations D. They are required for all Python programs Venvs prevent dependency conflicts.

47. What does copy.deepcopy() handle that copy.copy() doesn't? A. Immutable objects B. Nested mutable objects C. Thread locks D. Private attributes Deepcopy recursively copies structures. 48. Which data structure is best for priority queues? A. deque B. dict C. set D. heapq Heap supports efficient priority operations. 49. What does all control in a module? A. Imports from site-packages B. **Names imported by from module import *** C. Execution order D. Bytecode compiling all defines public API. 50. What does typing.Protocol allow?

A. Asynchronous execution B. Structural subtyping C. Bytecode optimization D. Data encryption Protocols provide duck-typing interfaces.

51. Which function in itertools repeats a value indefinitely? A. cycle B. count C. repeat D. chain repeat(x) yields x endlessly (or a set number of times). 52. Which serialization format is supported natively by Python’s standard library? A. YAML B. BSON C. TOML D. JSON The json module is built-in. 53. What is the time complexity of accessing an element in a Python dict? A. O(n) B. O(1) average case C. O(log n) D. O(n log n) Dicts use hash tables for average O(1) lookup.

D. module.call import_module() loads modules at runtime.

58. Which function inspects the current stack? A. sys.level B. traceback.stack C. inspect.stack D. os.path.stack inspect.stack() returns call stack frames. 59. Which term describes multiple functions with same name but different parameter types? A. overriding B. overloading (emulated via singledispatch) C. shadowing D. recursion Python emulates overloading using functools.singledispatch. 60. What is the purpose of typing.TypedDict? A. Ordered dicts B. Dicts with specified key-value types C. Faster dicts D. Encrypted dicts TypedDict provides type checking for dict-like objects. 61. What does asyncio.gather() do? A. Cancels tasks B. Runs tasks sequentially

C. Runs multiple awaitables concurrently D. Creates a new event loop gather() awaits several coroutines at once.

62. A metaclass must inherit from: A. object B. any class C. type D. cls Metaclasses subclass type. 63. In a class, which attribute holds the namespace? A. object B. dict C. slots D. all Object and class namespaces are dictionaries unless slots is used. 64. Which module supports binary data packing? A. json B. struct C. csv D. re struct packs/unpacks binary data. 65. What does the walrus operator (:=) do?

69. In argparse, which method parses command-line arguments? A. parse B. parse_line C. parse_args D. execute Standard CLI parsing. 70. What does sys.exit() raise? A. Error B. StopIteration C. SystemExit D. BaseException Program termination occurs via SystemExit. 71. Which keyword introduces pattern matching? A. inspect B. typecheck C. match D. pattern Introduced in Python 3.10. 72. Which object guarantees FIFO ordering in multiprocessing? A. Pipe B. Lock C. Queue D. Event Queue is FIFO.

73. Which command builds a wheel package? A. python - m build wheel B. pip wheel install C. python - m build D. wheel build PEP 517 recommends python - m build. 74. Which operator checks identity? A. == B. === C. is D. eq is compares object identity. 75. In asyncio, what creates a task? A. async.create() B. await run() C. asyncio.create_task() D. Task() Schedules a coroutine. 76. Which exception is raised on invalid type conversions? A. SyntaxError B. TypeError C. FormatError D. ConversionError TypeError signals incompatible types.