Exam PCAP All QuestionsBrowse all questions from this exam
Question 102

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

    Correct Answer: B, C

    Expressions 'data' in Class.__dict__ and 'Var' in Class.__dict__ evaluate to True. The first checks if 'data' is an attribute of the Class, which it is. The second checks if 'Var' is an attribute of the Class; given the typo correction, 'Var' is indeed an attribute of Class and hence also evaluates to True.

Discussion
mazimirOptions: BC

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__)

Noarmy315Options: BC

B (also C if 'Var')

9prayerOptions: BC

Correct Answer should be BC

it_man_531Options: 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}) >>>

vlobachevskyOptions: BC

BC is correct

dicksonpwcOptions: BC

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

dicksonpwcOptions: BC

The correct answer should be B and C

JnanadaOptions: BC

Correct Answer should be BC

macxszOption: B

only correct answer is: B. 'data' in Class.__dict__ If it was 'Var' instead, also: C. 'var' in Class.__dict__

Angel75Options: BC

Tested. BC

DTL001Options: BC

for me BC is correct