JNCIA-DevOps: Juniper Networks Certified Associate – Automation and DevOps — Question 1
Which statement is correct about Python variables once they are created?
Answer options
- A. A global variable can only be used by functions that are defined later
- B. All variables in Python can be used by any function within the script
- C. A global variable can be used by any function within the script
- D. A global can only be used within the function that created it
Correct answer: A
Explanation
The correct answer is A because a global variable can only be accessed by functions that are defined after it in the code. Options B and C are incorrect as they imply unrestricted access to all variables, while D is wrong since a global variable is accessible to all functions, not just the one that created it.