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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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 (?) , you can switch to a simple comment.
Switch to a voting comment New
sadako11
Highly Voted 2 years, 3 months ago
dir(math) returns a list containing strings sys.path returns a list containing strings so the answer is C True
upvoted 5 times
rocky48
2 years, 1 month 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, 1 month 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 3 months, 2 weeks 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 ago
Selected Answer: C
It should be False
upvoted 1 times
cufta05
1 year ago
Sorry I meant A
upvoted 1 times
...
...
macxsz
2 years ago
Selected Answer: C
C. True
upvoted 3 times
...
rocky48
2 years, 2 months ago
Selected Answer: C
answer is C True
upvoted 2 times
rocky48
2 years, 1 month 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, 1 month 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, 4 months ago
print(b1,b2,b1 and b2) #True True True
upvoted 1 times
...
wacha1978
2 years, 7 months 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
2 years, 7 months 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 ...