Friday , September 20 2024

What will be the result of executing the following code? class A: pass class B(A): pass class C(B): pass print(issubclass(C,A))

Questions BankCategory: Python Essentials 2What will be the result of executing the following code? class A: pass class B(A): pass class C(B): pass print(issubclass(C,A))
What will be the result of executing the following code?

class A:
    pass
 
 
class B(A):
    pass
 
 
class C(B):
    pass
 
 
print(issubclass(C,A))
  • it will print False
  • it will print True
  • it will print 1
  • it will raise an exception

Explanation: The except branch is executed and intercepts the object carrying information about the exception. The args property, which is a tuple, gathers all arguments passed to the Exception class constructor: 1, 2, and 3. The len function computes the length of the tuple (i.e. 3), which is printed to the console.

More Questions: Python Essentials 2 – Module 3 Test