Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 76 discussion

Actual exam question from Python Institute's PCAP
Question #: 76
Topic #: 1
[All PCAP Questions]

What is the expected output of the following code?

  • A. False
  • B. None
  • C. True
  • D. 0
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
sadako11
Highly Voted 2 years, 9 months ago
dir(math) returns a list containing strings sys.path returns a list containing strings so the answer is C True
upvoted 6 times
rocky48
2 years, 8 months ago
>>> b1 = type(dir(math)[0]) is list >>> b2 = type(sys.path[-1]) is list >>> b1 False >>> b2 False >>> print(b1 and b2) Sorry the answer is False
upvoted 1 times
rocky48
2 years, 8 months ago
My bad, its checking for a list and not str, If it is checking for a str : Answer = True elseif checking for a list : Answer = False
upvoted 1 times
...
...
...
zantrz
Most Recent 10 months ago
True import math print(dir(math)) print(type(dir(math))) # <class 'list'> print(type(dir(math)) is list) # True print(type(dir(math)[0])) # <class 'str'> print(type(dir(math)[0]) is str) # True import sys print(type(dir(sys.path))) # <class 'list'> print(type(dir(sys.path)) is list) # True print(type(dir(sys.path)[-1])) # <class 'str'> print(type(dir(sys.path)[-1]) is str) # True
upvoted 1 times
...
cufta05
1 year, 6 months ago
Selected Answer: C
It should be False
upvoted 1 times
cufta05
1 year, 6 months ago
Sorry I meant A
upvoted 1 times
...
...
macxsz
2 years, 6 months ago
Selected Answer: C
C. True
upvoted 3 times
...
rocky48
2 years, 8 months ago
Selected Answer: C
answer is C True
upvoted 2 times
rocky48
2 years, 8 months ago
>>> b1 = type(dir(math)[0]) is list >>> b2 = type(sys.path[-1]) is list >>> b1 False >>> b2 False >>> print(b1 and b2) Sorry the answer is False
upvoted 1 times
rocky48
2 years, 8 months ago
My bad its checking for a list and not str, If it is checking for a str : Answer = True elseif checking for a list : Answer = False
upvoted 1 times
...
...
...
Noarmy315
2 years, 11 months ago
print(b1,b2,b1 and b2) #True True True
upvoted 1 times
...
wacha1978
3 years, 1 month ago
import sys import math print(dir(math)[0]) b1=type(dir(math)[0]) is str print(sys.path[-1]) b2=type(sys.path[-1]) is str print(b1 and b2 ) __doc__ /usr/lib/python3.7/site-packages True
upvoted 2 times
...
wacha1978
3 years, 1 month ago
import sys import math print(dir(math)[0]) b1=type(dir(math)[0]) is str print(sys.path[-1]) b2=type(sys.path[-1]) is str print(b1 and b2 )
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...