Certified Associate in Python Programming (PCAP-31-03) — Question 1

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)

Answer options

Correct answer: B

Explanation

The code checks if both 'dir(math)' and 'sys.path' are of type list. Since both conditions are true, the output of 'print(b1 and b2)' will be True. The other options are incorrect because None, 0, and False do not reflect the actual outcome of the code.