Question 108 of 511
Modules and PackageshardMultiple SelectObjective-mapped

Quick Answer

The answer is the PYTHONPATH environment variable, the directory containing the script being executed, and the site-packages directory. These three factors directly influence Python’s module search path, stored in sys.path, because the interpreter builds this list at startup by combining the directory of the input script, any paths specified in the PYTHONPATH variable, and the default site-packages directory where pip installs third-party libraries. On the Certified Associate Python Programmer PCAP exam, this question tests your understanding of how Python locates modules during import, often appearing as a multiple-select item. A common trap is forgetting that the current working directory is not automatically included—only the script’s directory is—or assuming that PYTHONPATH overrides everything, when it simply prepends to sys.path. To remember the three factors, think of the mnemonic “Script, Variable, Site”: the script’s directory, the PYTHONPATH variable, and the site-packages folder.

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.

Which THREE factors influence Python's module search path (sys.path)?

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 site-packages directory where pip installs packages

Option C is correct because the site-packages directory is automatically included in sys.path by the site module during Python's initialization. This directory is the default location where pip installs third-party packages, making them importable without manual path manipulation.

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 HOME environment variable

    Why it's wrong here

    HOME is not directly used for sys.path.

  • The current working directory at runtime

    Why it's wrong here

    Not added automatically; only the directory of the script is added.

  • The site-packages directory where pip installs packages

    Why this is correct

    Appended when site module is processed.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The directory containing the script being executed

    Why this is correct

    Added to sys.path[0] for the main script.

    Related concept

    Read the scenario before looking for a memorised answer.

  • The PYTHONPATH environment variable

    Why this is correct

    Preprended to sys.path.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Python Institute often tests the distinction between the current working directory at runtime and the directory containing the script being executed, leading candidates to incorrectly assume the working directory is always searched for modules.

Detailed technical explanation

How to think about this question

Python's sys.path is built from several sources: the directory of the script (or current directory for interactive mode), PYTHONPATH environment variable, and site-packages directories (including user site-packages). The site module, executed at startup, reads .pth files and adds directories like site-packages. A subtle behavior is that the current working directory is only added if it is the script's directory or if Python is run interactively; changing the working directory at runtime does not update sys.path.

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 site-packages directory where pip installs packages — Option C is correct because the site-packages directory is automatically included in sys.path by the site module during Python's initialization. This directory is the default location where pip installs third-party packages, making them importable without manual path manipulation.

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

Same concept, more angles

2 more ways this is tested on PCAP

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A script runs: import sys; print(sys.path[0]). The output is an empty string. What does this indicate?

hard
  • A.The script is being read from stdin.
  • B.Python was launched with the -I flag.
  • C.The current working directory is not in sys.path.
  • D.The script is running from an interactive shell.

Why A: When a script is read from stdin (e.g., via `python < script.py` or `echo 'print(1)' | python`), Python sets `sys.path[0]` to an empty string because there is no script file path to derive the directory from. This is the documented behavior: `sys.path[0]` is the directory containing the script, or an empty string if the script is read from standard input.

Variation 2. A Python script fails with 'ModuleNotFoundError: No module named 'myapp.config''. The environment variable PYTHONPATH is not set. Which of the following is the most likely cause?

medium
  • A.The module is located in a directory not included in sys.path
  • B.The module's __init__.py is missing
  • C.The module is installed in a different Python version's site-packages
  • D.The module has a syntax error

Why A: When PYTHONPATH is not set, Python relies solely on sys.path to locate modules. sys.path includes the script's directory, standard library paths, and site-packages. If 'myapp.config' is not in any of these directories, Python raises ModuleNotFoundError. Option A correctly identifies that the module is in a directory not included in sys.path.

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.