Question 253 of 511
Modules and PackageseasyMultiple ChoiceObjective-mapped

Quick Answer

The answer is that PYTHONPATH must point to the parent directory of the 'team' namespace package, not directly to the subdirectories. This is because namespace packages work by having Python look for a directory without an `__init__.py` file—here, the `/team/` directory—and then merging any subdirectories (like `common` and `analytics`) found under that parent path. When you set PYTHONPATH to `/team/common/` and `/team/analytics/`, Python treats each as a separate top-level package, so it never discovers the `team` namespace, causing the `ModuleNotFoundError`. On the PCAP exam, this tests your understanding of how Python resolves namespace packages versus regular packages, and it’s a common trap where candidates mistakenly point PYTHONPATH to the subpackage directories instead of the namespace root. A reliable memory tip: think of PYTHONPATH as the “launchpad” for the namespace—it should always point to the folder that *contains* the namespace folder, not the folders inside it.

PCAP Modules and Packages Practice Question

This PCAP practice question tests your understanding of modules and packages. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Your team is developing a large application with many packages. To avoid name conflicts, you decide to use namespace packages. You have two directories: /team/common/ and /team/analytics/. Both contain an __init__.py file. You want to create a namespace package 'team' that combines these two directories. You create a directory /team/ with no __init__.py. You then set PYTHONPATH to /team/common/ and /team/analytics/ (actually, you set it to the parent directories). But when you try to `from team.common import something`, you get ModuleNotFoundError. What is the most likely reason?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The PYTHONPATH should point to the parent directory of 'team', not to the subdirectories directly.

Option B is correct because for namespace packages to work, PYTHONPATH must point to the parent directory of the 'team' namespace package, not to the subdirectories 'common' and 'analytics' directly. When PYTHONPATH includes '/team/common/' and '/team/analytics/', Python treats each as a separate top-level package, so 'from team.common import something' fails because 'team' is not found as a package. The correct setup is to set PYTHONPATH to the directory containing 'team' (e.g., '/team/'), allowing Python to discover 'team' as a namespace package and then locate 'common' and 'analytics' as sub-packages.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The presence of __init__.py in 'common' and 'analytics' prevents them from being part of a namespace package.

    Why it's wrong here

    Regular packages (with __init__.py) can be merged into a namespace package if the parent directory without __init__.py exists.

  • The PYTHONPATH should point to the parent directory of 'team', not to the subdirectories directly.

    Why this is correct

    Python expects the namespace package 'team' to be a directory directly under a path in sys.path.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The namespace package requires an __init__.py in the parent directory as well.

    Why it's wrong here

    Namespace packages are specifically directories without __init__.py.

  • The sys.path must also include the 'team' directory itself.

    Why it's wrong here

    Including the 'team' directory would be wrong; Python would treat 'team' as a top-level package.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often assume __init__.py is always required for packages, leading them to think its presence in subdirectories is the problem (Option A), or they mistakenly believe the namespace package itself needs an __init__.py (Option C), when in fact the key requirement is that the parent directory must be __init__.py-free and PYTHONPATH must point to the parent of the namespace package, not to the subdirectories.

Detailed technical explanation

How to think about this question

Namespace packages, introduced in PEP 420, allow a package to be split across multiple directories on the filesystem without requiring an __init__.py in the parent directory. Python's import machinery uses the 'path importer' to scan each directory in sys.path for subdirectories matching the package name; if multiple directories contain subdirectories with the same name and no __init__.py, they are merged into a single namespace package. This is particularly useful for large projects where different teams maintain separate components that logically belong to the same top-level package, such as a 'team' package with 'common' and 'analytics' sub-packages hosted in different repositories.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Modules and Packages — This question tests Modules and Packages — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The PYTHONPATH should point to the parent directory of 'team', not to the subdirectories directly. — Option B is correct because for namespace packages to work, PYTHONPATH must point to the parent directory of the 'team' namespace package, not to the subdirectories 'common' and 'analytics' directly. When PYTHONPATH includes '/team/common/' and '/team/analytics/', Python treats each as a separate top-level package, so 'from team.common import something' fails because 'team' is not found as a package. The correct setup is to set PYTHONPATH to the directory containing 'team' (e.g., '/team/'), allowing Python to discover 'team' as a namespace package and then locate 'common' and 'analytics' as sub-packages.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 24, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.