Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
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.
Its: True True False False
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)
A. isinstance (obj_b,A) B. A.VarA == 1
The correct answer is AB
Correct Answer : A,B
Correct Answer : A,B
Correct Answer : A,B
this is a,b
A and B are correct ones
A and B are the only True
AB is correct
>>> isinstance(obj_b, A) True >>> A.VarA == 1 True >>> obj_a is obj_aa False >>> B.VarA == 1 False
AB is correct