Courseiva

PCAP · topic practice

Modules and Packages practice questions

Practise Certified Associate Python Programmer PCAP Modules and Packages practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
20 questionsDomain: Modules and Packages

What the exam tests

What to know about Modules and Packages

Modules and Packages questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Modules and Packages exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Modules and Packages questions

20 questions · select your answer, then reveal the explanation

A developer is working on a project that requires the use of a third-party package hosted on a private repository. The developer wants to ensure that the package can be imported without specifying the full repository URL each time. Which approach should be taken?

A developer creates a package named 'analytics' with the following structure:

analytics/ __init__.py stats.py models/ __init__.py regression.py

The developer wants the statement 'from analytics import *' to import only the functions 'mean' and 'std' from stats.py. What should be added to analytics/__init__.py?

A developer is troubleshooting an ImportError: 'No module named 'config''. The config module is located in a subdirectory 'utils' relative to the script. The script's current working directory is the parent of 'utils'. Which of the following lines, added to the script, will resolve the issue?

A developer wants to import a specific function 'calculate' from a module named 'formulas' without importing the entire module. Which import statement should be used?

A developer is creating a package that contains a subpackage. The subpackage has an __init__.py file that imports a module named 'helper' from the parent package. Which import statement in the subpackage's __init__.py will correctly import 'helper'?

Question 6mediummultiple choice
Study the full Python automation breakdown →

A developer is troubleshooting a Python application that fails to import a custom module named 'utils'. The file 'utils.py' exists in the same directory as the main script. Which of the following is the most likely cause of the import failure?

A programmer wants to create a package named 'analytics' with subpackages 'statistics' and 'ml'. Which directory structure correctly defines these packages?

A Python package 'shapes' has the following __init__.py:

# shapes/__init__.py
from .circle import Circle
from .square import Square

A user writes:

import shapes

c = shapes.Circle(5)

This works correctly. However, when the user writes:

import shapes.circle

c = shapes.circle.Circle(5)

It fails with AttributeError: module 'shapes' has no attribute 'circle'. What is the most likely reason?

Which TWO of the following statements about Python packages are true?

Which THREE of the following are valid ways to import a function named 'calculate' from a module named 'math_ops' located in a subpackage 'operations' of a package 'app'?

Question 11mediummultiple choice
Study the full Python automation breakdown →

You are working on a Python-based data processing pipeline that runs on a Linux server. The pipeline consists of several custom packages and modules located in /opt/mypipeline. The directory structure includes:

/opt/mypipeline/ __init__.py core/ __init__.py processor.py utils/ __init__.py logger.py

The main entry point is /opt/mypipeline/run.py, which imports modules from core and utils. The pipeline is executed using the command:

python /opt/mypipeline/run.py

Recently, the system administrator added a new Python package 'external_lib' to /opt/external_lib, and updated the PYTHONPATH environment variable to include /opt/external_lib. However, after this change, the pipeline fails to start with the following error:

ImportError: cannot import name 'process' from 'core.processor' (unknown location)

You check the PYTHONPATH and find it contains:

/opt/mypipeline:/opt/external_lib

The 'core.processor' module defines a function 'process' that is imported in run.py as:

from core.processor import process

The 'core' package has an __init__.py file. The 'external_lib' package also has a subpackage named 'core' with an __init__.py. What is the most likely cause of the import error?

Given the exhibit, why does `dir()` show no names from `mypackage` after executing `from mypackage import *`?

Exhibit

Refer to the exhibit.

```
# file: mypackage/__init__.py
from . import module1
from .module2 import func2
__all__ = ['module1', 'func2']
```

```
# file: mypackage/module2.py
def func2():
    print('func2')
```

```python
>>> from mypackage import *
>>> dir()
['__builtins__', ...]
```

Drag and drop the steps to create and activate a virtual environment in Python into the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

Drag and drop the steps to create a simple HTTP server using the http.server module in Python into the correct order.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5

Match each Python built-in function to its description.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Returns the length of an object

Generates a sequence of numbers

Returns a sorted list from an iterable

Returns index and value pairs

Aggregates elements from multiple iterables

Match each code snippet to its output.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

8

3

1

15

14

A script is located in the parent directory of a package named 'mypackage'. Which import statement correctly imports the 'foo' module from the 'mypackage' package?

Question 18mediummultiple choice
Study the full Python automation breakdown →

When importing a module, Python searches for it in a specific order. Which of the following lists the correct order of directories searched?

Which TWO statements about namespace packages are true?

Which THREE factors can cause an 'ImportError' when trying to import a module?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Modules and Packages sessions

Start a Modules and Packages only practice session

Every question in these sessions is drawn from the Modules and Packages domain — nothing else.

Related practice questions

Related PCAP topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the PCAP exam test about Modules and Packages?
Modules and Packages questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Modules and Packages questions in a focused session?
Yes — the session launcher on this page draws every question from the Modules and Packages domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other PCAP topics?
Use the topic links above to move to related areas, or go back to the PCAP question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the PCAP exam covers. They are not copied from any real exam or dump site.