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.)
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.)
ClassB inherits from ClassA, so len(ClassB.__bases__) equals 1, not 2. Therefore, option A is false. In Python, the special attribute __module__ of a class will return '__main__' if the class is defined in the main script file being run, which makes option B true. The special variable __name__ will never equal 'code.py'; it will be '__main__' if the script is run directly and the module name if imported, making option C false. The __str__ method of ClassA returns None, so calling str(Object) will not equal 'Object', making option D false.
Ans A,as len(ClassB.__bases__) =1,after compiled ,it show '1'. Ans B, as ClassA.__module__ == '__main__', after compiled, it return true. Ans C, __name__ = __main__, so __name__ != 'code.py', return is false. Ans D, (str(Object) == 'Object',after compiled , it show 'TypeError' Correction: if you add a comma at the front and the end of the "Object" word, after compiled, it will return true print(str('Object') == 'Object') # Ans D, return true Only B is correct Answer!!
print(str('Object') == 'Object') out of context of the question
A. False B. True C. False D. TypeError Should be B
Only B should be valid:
Only B is valid str(Object) == "Object" Out[44]: False
The only expressions evaluating True is B
only: B. ClassA.__module__ == '__main__'