CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Imports and sys.path

PCAP objective 1.1 is import and use modules and packages, and it is the first subject in either syllabus that PCEP does not mention. There are five import forms and each binds different names - which is the whole examinable content, because `from math import pi` gives you `pi` and specifically does not give you `math`. Beyond that: the two import failures raise different exceptions, and a module body runs exactly once no matter how many times you import it.

Modules and Packages Guide 4 of 25 Intermediate

Written against the versions above. `ModuleNotFoundError` was added in Python 3.6 as a subclass of `ImportError`; older material says `ImportError` for a missing module and is not wrong, just less specific. Everything else here is unchanged since Python 3.0.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. The five import forms

  2. What from ... import specifically does not give you

  3. The two ways an import fails

  4. Where Python looks

  5. Not every module is a file

  6. What a module offers

  7. A module body runs once, however often you import it

  8. __name__ tells a file how it was started

  9. What the exam does with this objective

Official sources