Question 139 of 511
Modules and PackagesmediumMultiple ChoiceObjective-mapped

Quick Answer

The correct choice is to package the library as a proper Python package and install it via pip in each project's virtual environment. This approach aligns with PEP 517/518 and the principle of explicit dependency management, ensuring that each project declares its dependencies cleanly rather than relying on fragile sys.path modifications or symbolic links. On the PCAP exam, this question tests your understanding of Python packaging standards and the importance of reproducible environments—a common trap is choosing to copy the code or use relative imports, which break version control and isolation. Remember that Pythonic code favors explicit, standardized tools over ad-hoc workarounds. A useful memory tip: "Pip it, don't copy it"—if you need to share code across projects, package it and let pip handle the distribution, just like any third-party library.

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 company has a shared internal library stored in a Git repository. Developers need to use this library in multiple projects without copying the code. Which approach is the most Pythonic and maintainable?

Question 1mediummultiple choice
Study the full Python automation breakdown →

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

Package the library as a proper Python package and install it via pip in each project's virtual environment.

Option C is correct because packaging the library as a proper Python package and installing it via pip in each project's virtual environment follows the Python packaging standard (PEP 517/518) and the principle of explicit dependency management. This approach ensures versioning, isolation, and easy updates without modifying sys.path or relying on fragile filesystem links, making it the most maintainable and Pythonic solution.

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.

  • Add the library's directory to sys.path in each project's main script.

    Why it's wrong here

    Works but is not standard; versioning issues.

  • Create a symbolic link to the library's directory inside each project.

    Why it's wrong here

    Unreliable across operating systems and not a Python standard.

  • Package the library as a proper Python package and install it via pip in each project's virtual environment.

    Why this is correct

    Best practice; ensures version control and isolation.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Copy the library source code into each project's directory.

    Why it's wrong here

    Duplicates code, making updates difficult.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the misconception that modifying sys.path or using symbolic links is acceptable for sharing code, when in fact the Pythonic and maintainable solution is to package the library and install it via pip.

Detailed technical explanation

How to think about this question

Under the hood, Python's import system uses sys.path to locate modules, but modifying it programmatically is considered an anti-pattern because it can interfere with virtual environments and installed packages. Proper packaging involves creating a setup.py or pyproject.toml file, building a wheel, and installing it with pip, which places the package in site-packages where it is resolved consistently. In a real-world scenario, using a private PyPI server or a requirements.txt file with a Git-based dependency (e.g., -e git+https://...) allows teams to pin versions and automate updates across projects.

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: Package the library as a proper Python package and install it via pip in each project's virtual environment. — Option C is correct because packaging the library as a proper Python package and installing it via pip in each project's virtual environment follows the Python packaging standard (PEP 517/518) and the principle of explicit dependency management. This approach ensures versioning, isolation, and easy updates without modifying sys.path or relying on fragile filesystem links, making it the most maintainable and Pythonic solution.

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.

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.