A

Admin • 833K Points
Coach

Q. What is the output of the following code?

Code:
class Test:
count = 0
def __init__(self):
Test.count += 1
print(Test.count)
  • (A) 0
  • (B) 1
  • (C) Error
  • (D) No output
  • Correct Answer - Option(A)
  • Views: 18
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

No object is created, so `__init__` is never called. Class attribute `count` remains 0.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.