- A
PYTHONPATH then sys.path
Why wrong: PYTHONPATH is prepended to sys.path, so it is searched before site-packages but after the current directory.
- B
[current directory] then PYTHONPATH then site-packages
Why wrong: PYTHONPATH and site-packages are already part of sys.path, not separate search paths.
- C
sys.path + [current directory]
Why wrong: The current directory is not appended after sys.path; it is inserted at the beginning.
- D
[current directory] + sys.path
Correct. Python first adds the script's directory to sys.path, then the rest of sys.path.
Quick Answer
The correct answer is that Python searches the current directory first, followed by the rest of sys.path. This order is defined by how Python constructs sys.path at startup: it begins with the directory of the input script (or the current working directory if run interactively), then appends directories from the PYTHONPATH environment variable, and finally adds installation-dependent default paths like site-packages. On the Certified Associate Python Programmer PCAP exam, this concept tests your understanding of the import system’s runtime behavior, often appearing as a multiple-choice question where distractors reverse the order or omit the current directory. A common trap is assuming PYTHONPATH takes precedence over the script’s directory, but Python always checks the local context first to allow overriding installed modules. For a quick memory tip, think “Local first, then path, then packages”—or simply remember that the current directory sits at the front of sys.path, so it gets searched before everything else.
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.
When importing a module, Python searches for it in a specific order. Which of the following lists the correct order of directories searched?
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
[current directory] + sys.path
When Python imports a module, it first searches the directory containing the input script (or the current working directory if no script is specified), then iterates through the directories listed in the PYTHONPATH environment variable, and finally checks the installation-dependent default paths (such as site-packages). This order is reflected in the composition of sys.path, which is built from the script directory, PYTHONPATH entries, and default site-packages. Option D correctly states that the current directory is searched before the rest of sys.path, which includes PYTHONPATH and site-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.
- ✗
PYTHONPATH then sys.path
Why it's wrong here
PYTHONPATH is prepended to sys.path, so it is searched before site-packages but after the current directory.
- ✗
[current directory] then PYTHONPATH then site-packages
Why it's wrong here
PYTHONPATH and site-packages are already part of sys.path, not separate search paths.
- ✗
sys.path + [current directory]
Why it's wrong here
The current directory is not appended after sys.path; it is inserted at the beginning.
- ✓
[current directory] + sys.path
Why this is correct
Correct. Python first adds the script's directory to sys.path, then the rest of 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 misconception that PYTHONPATH is searched before the current directory, or that sys.path is a static list rather than a dynamically built sequence starting with the script's directory.
Detailed technical explanation
How to think about this question
Under the hood, when Python starts, it builds sys.path by first adding the directory of the script being run (or the current working directory if interactive), then appending entries from the PYTHONPATH environment variable, and finally adding installation-specific paths like site-packages. This means that a module in the current directory can shadow a module with the same name in PYTHONPATH or site-packages, which is a common source of import errors in larger projects. For example, if you have a local file named 'json.py', it will be imported instead of the standard library json module, potentially breaking code that expects the built-in behavior.
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.
- →
Modules and Packages — study guide chapter
Learn the concepts, then practise the questions
- →
Modules and Packages practice questions
Targeted practice on this topic area only
- →
All PCAP questions
511 questions across all exam domains
- →
Certified Associate Python Programmer PCAP study guide
Full concept coverage aligned to exam objectives
- →
PCAP practice test guide
How to use practice tests most effectively before exam day
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.
Modules and Packages practice questions
Practise PCAP questions linked to Modules and Packages.
Strings practice questions
Practise PCAP questions linked to Strings.
Object-Oriented Programming practice questions
Practise PCAP questions linked to Object-Oriented Programming.
Exceptions and File I/O practice questions
Practise PCAP questions linked to Exceptions and File I/O.
PCAP fundamentals practice questions
Practise PCAP questions linked to PCAP fundamentals.
PCAP scenario practice questions
Practise PCAP questions linked to PCAP scenario.
PCAP troubleshooting practice questions
Practise PCAP questions linked to PCAP troubleshooting.
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: [current directory] + sys.path — When Python imports a module, it first searches the directory containing the input script (or the current working directory if no script is specified), then iterates through the directories listed in the PYTHONPATH environment variable, and finally checks the installation-dependent default paths (such as site-packages). This order is reflected in the composition of sys.path, which is built from the script directory, PYTHONPATH entries, and default site-packages. Option D correctly states that the current directory is searched before the rest of sys.path, which includes PYTHONPATH and site-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.
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 →
Last reviewed: Jun 30, 2026
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.
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.
Sign in to join the discussion.