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 102 discussion

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

Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)

  • A. len(Class.__dict__) == 1
  • B. 'data' in Class.__dict__
  • C. 'var' in Class.__dict__
  • D. 'data' in Object.__dict__
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

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
mazimir
Highly Voted 3 years, 1 month ago
There is a typo in answer C. "var" should be capitalized "Var": class Class: Var = data = 1 def __init__(self,value): self.prop = value Object = Class(2) print(len(Class.__dict__) == 1) # False print("data" in Class.__dict__) # True print("Var" in Class.__dict__) # True print("data" in Object.__dict__) # False print(Class.__dict__) print("*************") print(Object.__dict__)
upvoted 13 times
...
dicksonpwc
Most Recent 1 year, 7 months ago
print(isinstance(obj_b,A)) # ans A, The isinstance() function returns True # if the specified object is of the specified type # return false print(A.VarA ==1) # ans B, A.VarA = 1, so A.VarA ==1. Then,it return true print(obj_a is obj_aa) # ans C, return false print(B.VarA == 1) # ans D, B.VarA = 2, so B.VarA not == 1. Then, it return false The correct answer should be B,C
upvoted 1 times
...
dicksonpwc
1 year, 7 months ago
The correct answer should be B and C
upvoted 1 times
...
9prayer
1 year, 9 months ago
Selected Answer: BC
Correct Answer should be BC
upvoted 2 times
...
Jnanada
2 years, 3 months ago
Correct Answer should be BC
upvoted 1 times
...
macxsz
2 years, 6 months ago
Selected Answer: B
only correct answer is: B. 'data' in Class.__dict__ If it was 'Var' instead, also: C. 'var' in Class.__dict__
upvoted 1 times
...
Angel75
2 years, 9 months ago
Selected Answer: BC
Tested. BC
upvoted 1 times
...
it_man_531
2 years, 10 months ago
Selected Answer: BC
>>> Object.__dict__ {'prop': 2} >>> Class.__dict__ mappingproxy({'__module__': '__main__', 'Var': 1, 'data': 1, '__init__': <function Class.__init__ at 0x100efd040>, '__dict__': <attribute '__dict__' of 'Class' objects>, '__weakref__': <attribute '__weakref__' of 'Class' objects>, '__doc__': None}) >>>
upvoted 2 times
...
Noarmy315
2 years, 11 months ago
B (also C if 'Var')
upvoted 3 times
...
DTL001
2 years, 11 months ago
for me BC is correct
upvoted 1 times
...
vlobachevsky
3 years, 1 month ago
BC is correct
upvoted 2 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 ...