Courseiva
Modules and Packages →mediumMultiple Select

PCAP Modules and Packages Practice Question

Which TWO statements about the sys module are true?

⚠ Common exam trap

Python Institute often tests the distinction between mutable and immutable types (list vs. tuple) and between data structures (list vs. dict) for `sys.path` and `sys.modules`, as well as the fact that `sys` is not a built-in module that is auto-imported.

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

✓

sys.exit() raises SystemExit with a default exit code of 0.

`sys.exit()` raises the `SystemExit` exception, and when called without an argument, the default exit code is 0, indicating successful termination. This behavior is defined in the Python documentation for the `sys` module.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    sys.path is a tuple of module search paths.

    Why it's wrong here

    sys.path is not a tuple; it is a mutable list of directory path strings that Python searches when resolving import statements. Being a list allows runtime modifications such as sys.path.append('/my/libs') to add a search directory, whereas a tuple would be immutable and would block this common developer action. The order of entries in sys.path also determines which module version is found first, making it a dynamic, editable container rather than a fixed sequence.

  • ✗

    sys.modules is a list of all loaded modules.

    Why it's wrong here

    sys.modules is actually a dictionary, not a list, because it must map module names such as 'math' to the corresponding module objects that have already been loaded. This dictionary serves as an import cache so that re-importing the same module does not execute it again, and a list could not provide efficient name-based lookup or hold paired name-object data. Manually inspecting or modifying sys.modules is a common technique for mocking or forcing reloads, which is only possible because it is a mutable dictionary.

  • ✓

    sys.exit() raises SystemExit with a default exit code of 0.

    Why this is correct

    Calling sys.exit() stops a Python program by raising the SystemExit exception, and when no status argument is supplied the exit code is 0, meaning successful termination. The absence of an argument is equivalent to passing None, which the interpreter treats as 0 for the process exit status. Because SystemExit is an exception, code in finally blocks still runs, and an outer try/except can intercept it, so sys.exit() is not an abrupt low-level kill.

  • ✗

    The sys module is automatically imported in every Python script.

    Why it's wrong here

    The sys module is not automatically imported into the global namespace of every script; you must explicitly write import sys before referencing sys.argv, sys.path, or any other sys attribute. Python's interpreter has a sys object internally at startup, but that internal module is not bound to the name sys in your script until the import statement executes. Without the import, code that tries to use sys raises a NameError, unlike built-in names such as print that are always available.

  • ✓

    sys.argv[0] is the script name.

    Why this is correct

    sys.argv is a list of command-line strings, and sys.argv[0] always holds the script name that was passed to the Python interpreter, not the first user-provided argument. In a command like python script.py alpha beta, script.py is replaced by sys.argv[0] while alpha and beta occupy indices 1 and 2. Interactive sessions or code run with -c set this entry to an empty string or '-c', so programs should skip index 0 when processing actual arguments.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.