Question 451 of 511
Modules and PackageshardMultiple ChoiceObjective-mapped

Quick Answer

The answer is that the submod1 module does not define a function named 'func'. This is the most likely cause because an AttributeError after import always means the attribute you are trying to access does not exist on the object you are referencing. In this case, the import statement in __init__.py correctly exposes submod1 as an attribute of mypkg, so the error cannot be from a failed import—it must be that submod1.py itself lacks a definition for func. On the Certified Associate Python Programmer PCAP exam, this question tests your understanding of how Python resolves module attributes versus function definitions, a common trap where learners blame the import mechanism instead of checking the module’s contents. Remember the memory tip: “Import gets you the module, but the module must own the function.”

PCAP Modules and Packages Practice Question

This PCAP practice question tests your understanding of modules and packages. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. 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 package 'mypkg' has the following structure: mypkg/ __init__.py submod1.py submod2.py The __init__.py file contains: from . import submod1, submod2. A user runs 'import mypkg' and then 'mypkg.submod1.func()'. However, the user got an AttributeError. What is the most likely cause?

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.

Question 1hardmultiple choice
Full question →

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 submod1 module does not define a function named 'func'.

Option C is correct because the AttributeError indicates that the attribute 'func' was not found on the module object 'submod1'. Since the import statement in __init__.py correctly makes submod1 accessible as mypkg.submod1, the only remaining reason for the error is that submod1.py does not define a function named 'func'. The import mechanism itself is working as intended.

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.

  • submod1 is actually a package, not a module, so it cannot be called with 'func()'.

    Why it's wrong here

    If it were a package, it would need an __init__.py; no evidence.

  • The __init__.py should use absolute imports like 'import mypkg.submod1' to make submod1 accessible.

    Why it's wrong here

    Absolute imports also work, but relative imports are fine.

  • The submod1 module does not define a function named 'func'.

    Why this is correct

    The AttributeError indicates that the attribute 'func' does not exist in submod1.

    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 user must also run 'from mypkg import submod1' before accessing submod1.

    Why it's wrong here

    The __init__.py already imports submod1, so it is accessible.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests whether candidates understand that an AttributeError on a module attribute (like a function) is distinct from an ImportError or ModuleNotFoundError, leading them to incorrectly suspect the import mechanism rather than the missing definition in the module.

Detailed technical explanation

How to think about this question

When a package is imported, Python executes its __init__.py, which populates the package's namespace. The relative import 'from . import submod1' binds the name 'submod1' in the mypkg namespace to the module object. The AttributeError occurs only when the subsequent attribute lookup for 'func' fails on that module object. This is a common debugging scenario: the import chain works, but the expected function is missing from the module.

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 media company stores terabytes of video archives that are accessed once a year for audit purposes. Moving these objects to a cold storage tier (Azure Archive, S3 Glacier, or Google Nearline) costs a fraction of hot storage. Questions like this test whether you understand storage tiers, access frequency tradeoffs, and retrieval latency requirements.

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 submod1 module does not define a function named 'func'. — Option C is correct because the AttributeError indicates that the attribute 'func' was not found on the module object 'submod1'. Since the import statement in __init__.py correctly makes submod1 accessible as mypkg.submod1, the only remaining reason for the error is that submod1.py does not define a function named 'func'. The import mechanism itself is working as intended.

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

Keep practising

More PCAP practice questions

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.