Certified Associate in Python Programming (PCAP) — Question 83
A 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. import pymod pymod.pyvar = 1
- B. import pyvar from pymod pyvar = 1
- C. from pymod import pyvar pyvar ()
- D. from pyfun import * pyvar = 1
Correct answer: A
Explanation
Option A is correct because it correctly imports the pymod module, allowing access to its variable pyvar. The other options are incorrect: B incorrectly attempts to import pyvar directly, C improperly tries to call pyvar as a function, and D imports from a different module, pyfun, which does not contain pyvar.