Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCAP-31-03 Topic 1 Question 88 Discussion

Actual exam question for Python Institute's PCAP-31-03 exam
Question #: 88
Topic #: 1
[All PCAP-31-03 Questions]

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? (Select two answers)

Show Suggested Answer Hide Answer
Suggested Answer: B, D

Contribute your Thoughts:

Nu
2 months ago
Wait, there's a class named 'ClassA' and another named 'ClassB'? I thought this was supposed to be a simple Python script, not some complex inheritance hierarchy!
upvoted 0 times
Alida
25 days ago
The expressions that evaluate to True are A) str(Object) == 'Object' and D) len(ClassB.__bases__) == 1.
upvoted 0 times
...
Miesha
1 months ago
Yes, there are two classes mentioned in the code.
upvoted 0 times
...
...
Albina
2 months ago
C) ClassA._module_ == 'ClassA' is a trick question. The `_module_` attribute doesn't exist, it's just a made-up name.
upvoted 0 times
Santos
7 days ago
B) _name == _main_' is False
upvoted 0 times
...
Kyoko
21 days ago
C) ClassA._module_ == 'ClassA' is a trick question
upvoted 0 times
...
Weldon
28 days ago
D) len(ClassB.__bases__) == 1 is True
upvoted 0 times
...
Lemuel
1 months ago
A) str(Object) == 'Object' is True
upvoted 0 times
...
...
Dahlia
2 months ago
A) str(Object) == 'Object' is not correct. The `str()` function returns the string representation of an object, which may not necessarily be 'Object'.
upvoted 0 times
...
Kina
2 months ago
D) len(ClassB.__bases__) == 1 is also correct. The `__bases__` attribute of a class returns a tuple of its base classes, and we're checking the length of this tuple.
upvoted 0 times
Merilyn
22 days ago
D) len(ClassB.__bases__) == 1 is also correct.
upvoted 0 times
...
Jina
1 months ago
C) ClassA. _module_ == 'ClassA'
upvoted 0 times
...
Jannette
1 months ago
A) str(Object) == 'Object'
upvoted 0 times
...
...
Karan
3 months ago
I believe option D) len(ClassB.__bases__) == 1 is also True, as it checks the number of base classes for ClassB.
upvoted 0 times
...
Ciara
3 months ago
B) _name == _main_ is the correct answer. The `__name__` variable is set to `'__main__'` when the script is executed directly, and to the module name when it's imported.
upvoted 0 times
Paz
2 months ago
B) _name == _main_'
upvoted 0 times
...
King
2 months ago
A) str(Object) == 'Object'
upvoted 0 times
...
...
Barabara
3 months ago
I agree with Miss, option A) makes sense because it's comparing a string representation of an object.
upvoted 0 times
...
Miss
3 months ago
I think option A) str(Object) == 'Object' is True.
upvoted 0 times
...

Save Cancel