Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 57

Assuming that the code below has been placed inside a file named code.py and executed successfully, which of the following expressions evaluate to True? (Choose two.)

    Correct Answer: C, D

    First, 'str(Object) == 'Object'' evaluates to True because the __str__ method is defined in ClassA, and ClassB inherits from ClassA. Thus, when str() is called on an instance of ClassB (which is 'Object'), it returns 'Object'. Secondly, 'ClassA.__module__ == '__main__'' evaluates to True because when the code is executed directly, the __module__ attribute for any class in that file is set to '__main__'. Option A is incorrect as ClassB has only one base class, ClassA, so len(ClassB.__bases__) == 2 would be false. Option B is also incorrect because __name__ holds the name of the module, which would be '__main__' during execution.

Discussion
DKAT2023Option: D

only D are correct, C not correct should be : _str_(Object) == 'Object'