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 questionsIn 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.
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.
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."
Keep practicing
Take the free JN0-223 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JN0-223 practice questions
- Question 1Which two programming languages have a NETCONF library supported by Juniper Networks? (Ch…
- Question 2A REST API client uses which two HTTP methods to execute RPC requests on the server? (Cho…
- Question 3Which statement is valid regarding YAML and JSON?
- Question 4Which two statements about the REST API are correct? (Choose two.)
- Question 5Which development model is the classic approach to software development?
- Question 6Which statement is correct about DevOps?
