nerdexam
Databricks

CERTIFIED-DATA-ENGINEER-PROFESSIONAL · Question #54

Which Python variable contains a list of directories to be searched when trying to locate required modules?

The correct answer is B. sys.path. sys.path is a built-in Python list (part of the sys module) that defines the order of directories Python searches when resolving import statements. When you write 'import mymodule', Python iterates through each directory in sys.path until it finds the module or raises a…

Python Programming Fundamentals

Question

Which Python variable contains a list of directories to be searched when trying to locate required modules?

Options

  • Aimportlib.resource path
  • Bsys.path
  • Cos-path
  • Dpypi.path
  • Epylib.source

How the community answered

(38 responses)
  • B
    95% (36)
  • D
    3% (1)
  • E
    3% (1)

Explanation

sys.path is a built-in Python list (part of the sys module) that defines the order of directories Python searches when resolving import statements. When you write 'import mymodule', Python iterates through each directory in sys.path until it finds the module or raises a ModuleNotFoundError. sys.path is initialized from the PYTHONPATH environment variable, the installation-dependent default, and the directory containing the script being run. You can dynamically append to sys.path at runtime to include custom directories. The other options are fabricated: 'importlib.resource path' is not a standard variable, 'os-path' does not exist (os.path is for filesystem path manipulation, not module searching), 'pypi.path' and 'pylib.source' are not real Python constructs.

Topics

#Python Modules#Module Import#sys module#Python Fundamentals

Community Discussion

No community discussion yet for this question.

Full CERTIFIED-DATA-ENGINEER-PROFESSIONAL Practice