A

Admin • 833.24K Points
Coach

Q. What will the following code print?
```python
class A:
def __init__(self, x):
self.x = x

a = A(10)
print(a.x)
```

  • (A) 0
  • (B) 10
  • (C) None
  • (D) Error
  • Correct Answer - Option(B)
  • Views: 33
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

The constructor sets `self.x` to 10, so `a.x` is 10.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.