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

A
10
C
Error
D
None
Solution:

get_x() accesses the private __x, returning 10 via encapsulation.

Entri Contact Image

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