In the given code snippet, an instance of OwnMath exception is raised with an explicitly specified __cause__ attribute that refers to the original exception (ZeroDivisionError). This is an example of explicitly chaining exceptions in Python.
Question # 5
Select the true statement related to PEP 257.
A.
String literals that occur immediately after another docstring are called attribute docstrings.
B.
Attribute docstrings and Additional docstrings are two types of extra docstrings that can be extracted by software tools.
C.
String Iiterals that occur in places other than the first statement in a module, function, or class definition can act as documentation They are recognized by the Python bytecode compiler and are accessible as runtime object attributes
D.
String literals that occur immediately after a simple assignment at the top level of a module are called complementary docstrings
The true statement related to PEP 257 is Option B. According to PEP 257, string literals occurring elsewhere in Python code may also act as documentation. They are not recognized by the Python bytecode compiler and are not accessible as runtime object attributes (i.e. not assigned to doc), but two types of extra docstrings may be extracted by software tools: String literals occurring immediately after a simple assignment at the top level of a module, class, or init method are called “attribute docstringsâ€. String literals occurring immediately after another docstring are called “additional docstringsâ€1.
Question # 6
What is true about type in the object-oriented programming sense?
A.
It is the bottommost type that any object can inherit from.
B.
It is a built-in method that allows enumeration of composite objects
C.
It is the topmost type that any class can inherit from
In Python, type is the built-in metaclass that serves as the base class for all new-style classes. All new-style classes in Python, including built-in types like int and str, are instances of the type metaclass and inherit from it.