Exam PCAP All QuestionsBrowse all questions from this exam
Question 101

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

    Correct Answer: A, B

    The expression 'isinstance(obj_b, A)' evaluates to True because class B inherits from class A, making an instance of B also an instance of A. The expression 'A.VarA == 1' is True because within the definition of class A, 'VarA' is explicitly set to 1. Thus, these two expressions are correct. The other options are incorrect because 'obj_a is obj_aa' evaluates to False since 'is' checks for identity, and 'obj_a' and 'obj_aa' are two separate instances. 'B.VarA == 1' is False because in class B, 'VarA' is set to 2.

Discussion
mazimirOptions: AB

Its: True True False False

Misco33

That's correct, try this code: class A: VarA = 1 def __init__(self) -> None: self.prop_a=1 class B(A): VarA = 2 def __init__(self) -> None: self.prop_b=2 obj_a = A() obj_aa = A() obj_b=B() obj_bb=B() print(isinstance(obj_b,A)) print(A.VarA==1) print(obj_a is obj_aa) print(B.VarA == 1)

macxszOptions: AB

A. isinstance (obj_b,A) B. A.VarA == 1

DTL001Options: AB

The correct answer is AB

kontraOptions: AB

Correct Answer : A,B

9prayerOptions: AB

Correct Answer : A,B

JnanadaOptions: AB

Correct Answer : A,B

blacksmokerrOptions: AB

this is a,b

deckmanOptions: AB

A and B are correct ones

macxszOptions: AB

A and B are the only True

rocky48Options: AB

AB is correct

rocky48

>>> isinstance(obj_b, A) True >>> A.VarA == 1 True >>> obj_a is obj_aa False >>> B.VarA == 1 False

Noarmy315Options: AB

AB is correct