Question 106 of 511
Modules and PackageshardMultiple ChoiceObjective-mapped

Quick Answer

The answer is that the submodule 'circle' is not accessible as an attribute because the package's __init__.py only imports the class Circle, not the submodule itself. When you write import shapes.circle, Python looks for 'circle' as an attribute of the shapes package, but the __init__.py only adds Circle and Square to the namespace—it never imports the submodule 'circle' as a whole. This tests your understanding of Python's package initialization and namespace mechanics, a common pitfall on the PCAP exam where candidates confuse importing a name from a submodule with importing the submodule itself. The key distinction is that from .circle import Circle makes Circle available, but the submodule 'circle' remains invisible unless explicitly imported with import shapes.circle inside __init__.py. For the exam, remember: importing a name does not import the module—think of it as taking a fruit from a tree without making the whole tree accessible.

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.

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?

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 submodule 'circle' is not added to the package's namespace because the __init__.py does not import it as a submodule.

Option A is correct because when a package's __init__.py imports specific names (like Circle) from submodules, it does not automatically make the submodule itself accessible as an attribute of the package. The submodule 'circle' is not added to the package's namespace unless explicitly imported as a submodule (e.g., using 'import shapes.circle' in __init__.py). Thus, 'import shapes.circle' fails because Python cannot find 'circle' in the package's namespace.

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 submodule 'circle' is not added to the package's namespace because the __init__.py does not import it as a submodule.

    Why this is correct

    The __init__.py only imports the class Circle, not the submodule name. When 'import shapes.circle' is executed, Python attempts to load the submodule and add it as an attribute, but if the submodule has import errors or is not a proper module, it may fail. However, the most likely reason is that the submodule import does not automatically make the submodule accessible via the package if the package's __init__.py does not import it. Actually, Python does add the submodule to the package after a successful import. But the error suggests that the import of shapes.circle failed silently? The correct answer is that the submodule is not loaded because of a circular import or because the submodule's name is the same as a class and Python gets confused. In PCAP, the typical answer is that importing the submodule using 'import shapes.circle' does not make 'circle' available as an attribute of 'shapes' unless the package's __init__.py explicitly imports it. I'll go with D.

    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 __init__.py file must include 'import shapes.circle' to make the submodule accessible.

    Why it's wrong here

    Even without explicit import, importing the submodule directly should add it to the package's namespace.

  • The submodule name 'circle' conflicts with the class name 'Circle' due to case sensitivity.

    Why it's wrong here

    Case sensitivity does not cause conflicts; 'circle' and 'Circle' are different.

  • The import statement 'import shapes.circle' is invalid because submodules must be imported using 'from' syntax.

    Why it's wrong here

    'import shapes.circle' is a valid syntax for importing submodules.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the misconception that importing names from a submodule (e.g., 'from .circle import Circle') automatically makes the submodule itself accessible as an attribute of the package, leading candidates to incorrectly think the submodule is available for direct import.

Detailed technical explanation

How to think about this question

Under the hood, when Python imports a package, it executes the __init__.py and adds any names defined there (like Circle) to the package's namespace. However, submodules are only added as attributes if they are explicitly imported (e.g., via 'import shapes.circle' or 'from . import circle'). This behavior is defined in PEP 302 and the import system's module caching; a submodule can exist on disk but remain inaccessible as an attribute until imported. In real-world scenarios, this often causes confusion when refactoring packages, as developers assume submodules are automatically available.

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 company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

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 submodule 'circle' is not added to the package's namespace because the __init__.py does not import it as a submodule. — Option A is correct because when a package's __init__.py imports specific names (like Circle) from submodules, it does not automatically make the submodule itself accessible as an attribute of the package. The submodule 'circle' is not added to the package's namespace unless explicitly imported as a submodule (e.g., using 'import shapes.circle' in __init__.py). Thus, 'import shapes.circle' fails because Python cannot find 'circle' in the package's namespace.

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 30, 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.