A

Admin • 833K Points
Coach

Q. What is the output of the following code?

Code:
class A:
def __init__(self):
self.var = 1

a = A()
print(a.var)
  • (A) None
  • (B) 1
  • (C) 0
  • (D) Error
  • Correct Answer - Option(B)
  • Views: 25
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

The constructor `__init__` initializes `self.var` to 1.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.