Jan 17 in Python
Q: What is the output of the following code?

class A:

    def __init__(self, value):

        self.x = value


    def x(self):

        return self.__x


    def x(self, value):

        if not isinstance(value, (int, float)):

            raise ValueError('Only Int or float is allowed')

        self.__x = value

a = A(7)

a.x = 'George'


a) George

b) AttributeError

c) 7

d) ValueError

1 Answer

0 votes
Jan 17
d) ValueError
Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
Dec 14, 2019 in Python