A Python module named pymod.py contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
A Python module named pymod.py contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
To invoke the function pyfun() from the module pymod, we can use two different snippets. The first approach is to import the entire module using 'import pymod', and then call the function with 'pymod.pyfun()'. The second approach is to import the specific function using 'from pymod import pyfun', and then directly call 'pyfun()'. Option A demonstrates the first method and option B demonstrates the second method. These both correctly allow the function to be invoked.
pymod.py file contains => pyvar = 1 def pyfun(): print(pyvar) python3 => >>> import pymod >>> pymod.pyfun() 1 >>> from pymod import pyfun >>> pyfun() 1 >>> from pymod import * >>> pymod.pyfun() 1 >>> import pyfun from pymod File "<stdin>", line 1 import pyfun from pymod ^ SyntaxError: invalid syntax A,B, C are all correct. But B is better than C. Best answer : A & B
for C we would require 3 lines, therefore I think is incorrect: import pymod from pymod import * pymod.pyfun()
A. import pymod pymod.pyfun() B. from pymod import pyfun pyfun()
There is no any correct answer if each statement write in a single line.
Yes, it's AB