PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 141


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

Show Answer
Correct Answer: AB

ClassA.__module__ == '__main__' evaluates to True because the code is assumed to be run in the main module context. __name__ == '__main__' also evaluates to True for the same reason. The other options are incorrect: str(Object) == 'Object' is False because Object is an instance of ClassA, which does not override the __str__ method, so it uses the default string representation of the object. len(ClassB.__bases__) == 2 is also False because ClassB has only one direct base class, which is ClassA.

Discussion

7 comments
Sign in to comment
macxszOptions: AB
Apr 30, 2022

True: A. ClassA.__module__ == '__main__' B. __name__ == '__main__'

simplex06Options: AB
Jul 21, 2022

class ClassA: var = 1 def __init__(self, prop): prop1 = prop2 = prop class ClassB(ClassA): def __init__(self, prop): prop3 = prop ** 2 super().__init__(prop) def __str__(self): return 'Object' Object = ClassA(2) A and B are True

JnanadaOptions: AB
Aug 18, 2022

A & B are true

AmfortasOptions: AB
Sep 5, 2022

A and B are True

Damon54
Feb 14, 2024

There are at least 45 completely wrong questions in this dump!!!!! be careful

kstrOptions: AB
Nov 17, 2023

AB tested

seaverickOptions: AB
Jan 28, 2024

class ClassA: var = 1 def __init__(self, prop): prop1 = prop2 = prop class ClassB(ClassA): def __init__(self, prop): prop3 = prop ** 2 super().__init__(prop) def __str__(self): return 'Object' Object = ClassA(2) print(ClassA.__module__ == '__main__') print(__name__ == '__main__') #print(str(Object) == 'Object')#TypeError: '_io.TextIOWrapper' object is not callable print(len(ClassB.__bases__) == 2) Ans is A,B