Which statement is correct about Python variables that are defined in the global namespace?
A.
Global variables are stored in disk storage and can be used by any Python script executed on this device.
B.
Global variables can only be referenced in the module's code within the global namespace.
C.
Global variables must have the data type explicitly declared.
D.
Global variables can be referenced in any portion of the module's code.
The Answer Is:
D
This question includes an explanation.
Explanation:
In Python's scoping model (frequently summarized by the LEGB rule: Local, Enclosing, Global, Built-in), variables defined at the top-level module scope reside within the global namespace of that specific module. Once defined, these global variables are accessible for reading throughout any portion of the module’s code, including inside nested functions, classes, and control flow blocks without requiring any special declarations (unless modified inside a local scope, which requires the global keyword). Python uses dynamic typing; variable data types are inferred at runtime based on the bound object rather than explicitly declared. Furthermore, Python variables reside strictly in active runtime memory during the lifetime of the process—they are not serialized to persistent disk storage for inter-script usage. Hence, global variables can be referenced throughout the module.
[Reference: JNCIA-DevOps Study Guide — Python Fundamentals: Variable Scope and Namespaces., ]
JN0-224 PDF/Engine
Printable Format
Value of Money
100% Pass Assurance
Verified Answers
Researched by Industry Experts
Based on Real Exams Scenarios
100% Real Questions
Get 75% Discount on All Products,
Use Coupon: "ac75sure"