Certified Associate in Python Programming (PCAP) — Question 65
A Python module named pymod.py contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
Answer options
- A. import pymod pymod.pyfun()
- B. from pymod import pyfun pyfun()
- C. from pymod import * pymod.pyfun()
- D. import pyfun from pymod pyfun()
Correct answer: A, B
Explanation
Options A and B are correct because they correctly import the function or module and then invoke the function. Option C is incorrect because it attempts to use pymod.pyfun() after importing everything from pymod, which can lead to confusion. Option D is invalid syntax for importing in Python.