Examers.io
ExamsOrganizationsHow it worksPricingHelp & FAQ
Python Institute logo

Python InstitutePCAP - Certified Associate Python Programmer

Domain 1Objective 5

PCAP-31-03 1.5 Create and Use User-Defined Modules and Packages PCAP-31 Practice Questions (Page 6)

Part of the Modules and Packages domain, which accounts for 12% of the PCAP-31 exam. Python Institute does not publish an official question count, but from its 65-minute exam (~25–45 total, ~3–5 in this domain), expect 1–1 from this objective — we provide 30 practice questions to prepare you well beyond it. (estimate)

30questions here
6free pages
8concepts
12%of the exam

Questions 26–30

  1. 26application · easy

    A developer has a module `math_helpers.py` that defines a function `add(a, b)` and a constant `_pi = 3.14159`. Another script imports the module with `import math_helpers`. The developer wants to use the `add` function but does not want to accidentally access `_pi`. What is the best practice for the developer to follow?

    Select an answer first
  2. 27expert · medium

    A developer has a package `payment` with the following `__init__.py`: ```python from . import gateway from . import validator __all__ = ['gateway', 'validator'] ``` The developer wants to add a new submodule `refund.py` to the package. The developer wants `from payment import *` to import `refund` as well. What change is required?

    Select an answer first
  3. 28application · medium

    A team is organizing shared code into a package named `analytics`. The package directory contains `analytics/__init__.py`, `analytics/stats.py`, and `analytics/plotting.py`. The team wants `from analytics import stats` to work, but they also want `import analytics` to automatically make the `stats` submodule available as `analytics.stats` without an explicit import. What should be added to `analytics/__init__.py`?

    Select an answer first
  4. 29foundation · easy

    If a directory contains subdirectories but no `__init__.py` files, how can its modules be imported?

    Select an answer first
  5. 30foundation · easy

    How can you add a directory to Python's module search path at runtime?

    Select an answer first
Finished these 5 questions?

Review the revealed explanations, or continue through the curriculum.

No more pagesBack to PCAP-31

Free Basic Practice is a study aid with revealable answers — not a scored exam. Examers.io is independent and not affiliated with or endorsed by Python Institute. “PCAP-31” is a trademark of its owner, used for identification only.