Certified Associate in Python Programming (PCAP-31-03) — Question 81
Python module named pymod.py contains a variable named pyvar.
Which of the following snippets will let you access the variable? (Choose two.)
Answer options
- A. from pymod import * pyvar = 1
- B. import pyvar from pymod pyvar = 1
- C. from pymod import pyvar pyvar()
- D. import pymod pymod.pyvar = 1
Correct answer: A, D
Explanation
Option A correctly imports all variables from pymod, allowing access to pyvar, while Option D imports the module and accesses pyvar via the module's namespace. Options B and C are incorrect due to syntax errors; B has the wrong import syntax, and C incorrectly attempts to call pyvar as a function.