Q. What is the output of class A: _x = 5 def get_x(self): return self._x a = A() print(a.get_x())?

A
5
C
Error
D
None
Solution:

get_x() accesses the protected _x, returning 5 as it’s accessible via methods.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!