JN0-223 practice question 14 of 15

You want to use a Python package or module. In this scenario, which statement would accomplish this task?

Full set: 66 questions
Answer options
A: reap
B: dir
C: input
D: Import Correct answer
Correct Answer:
D. Import
Explanation

In Python, the import statement is the standard and required method for loading and using external code contained within a module or a package. When a module is imported, Python executes the code in the module file and makes its functions, classes, and variables available in the current program's namespace. This allows for code reuse and modular program design, which are fundamental principles in software development and network automation scripts relevant to the JN0-223 exam. For example, import jnpr.junos would be used to access the Junos PyEZ library.

Why Incorrect

A. reap: This is not a Python keyword for importing. It is related to process management, such as in the os.wait() family of functions for handling child processes.
B. dir: This is a built-in function used for introspection. It returns a list of valid attributes for an object, not for loading or importing a module.
C. input: This is a built-in function used to prompt for and receive user input from the console, and it is unrelated to module management.

References

1. Official Python Documentation: The Python Tutorial

Chapter 6: Modules. Section 6.1

"More on Modules

" explicitly introduces the concept of modules and the import statement as the mechanism to use them. It states

"definitions from a module can be imported into other modules... This is done with the import statement."

Source: The Python Software Foundation

"The Python Tutorial

" Section 6. Modules.

2. Juniper Official Documentation: The "Junos PyEZ Getting Started Guide" consistently demonstrates the use of the import statement to use the library. For example

the first step in connecting to a device is shown as from jnpr.junos import Device

which is a form of the import statement.

Source: Juniper TechLibrary

"Junos PyEZ Getting Started Guide

" Section: Connect to a Junos Device.

3. University Courseware: MIT OpenCourseWare's "Introduction to Computer Science and Programming in Python" (6.0001) covers modules in Lecture 5. The lecture notes and video explain that import is the command used to gain access to the code within a module.

Source: MIT OpenCourseWare

6.0001SC

Lecture 5: Tuples

Lists

Aliasing

Mutability

Cloning

Section: "Modules."

Scroll to Top