Review 129 PCAP-31-03 practice questions with answer explanations and community insights.
Question 1
What is true about Python packages? (Choose two.)
a code designed to initialize a package’s state should be placed inside a file named init.py
a package’s contents can be stored and distributed as an mp3 file
__pycache__ is a folder that stores semi-compiled Python modules
the sys.path variable is a list of strings
Question 2
What is the expected output of the following code? import sys import math b1 = type(dir(math)) is list b2 = type(sys.path) is list print(b1 and b2)
None
True
0
False
Question 3
A Python package named pypack includes a module named pymod.py which contains a function named pyfun(). Which of the following snippets will let you invoke the function? (Choose two.)
Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Choose two.) import random v1 = random.random() v2 = random.random()
len(random.sample([1,2,3],1)) > 2
v1 == v2
random.choice([1,2,3]) > 0
v1>1
Question 5
With regards to the directory structure below, select the proper forms of the directives in order to import module_c. (Choose two.)