PCAP-31-03 Exam QuestionsBrowse all questions from this exam

PCAP-31-03 Exam - 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)

Show Answer
Correct Answer: B

In the given code, 'b1 = type(dir(math)) is list' checks if the return type of 'dir(math)' is a list, which it is. Similarly, 'b2 = type(sys.path) is list' checks if 'sys.path' is a list, which is also true. Since both b1 and b2 are true, 'print(b1 and b2)' will output True.

Discussion

5 comments
Sign in to comment
earawiranOption: B
May 17, 2024

import sys import math b1 = type(dir(math)) is list b2 = type(sys.path) is list print(b1 and b2) True

Nikhil_DurgeshOption: B
May 22, 2024

Correct Answer : B import sys import math b1 = type(dir(math)) is list b2 = type(sys.path) is list print(b1 and b2) Output : True

a4129fdOption: B
May 28, 2024

B is the right one: True

DKAT2023Option: B
Jun 28, 2024

B True

Dave304409Option: B
Jul 4, 2024

is correct