What is the output of the following code? class A: def __init__(self, value): self.x = value @property def x(self): return self.__x @x.setter 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' print(a.x)

Questions & AnswersCategory: Programming LanguageWhat is the output of the following code? class A: def __init__(self, value): self.x = value @property def x(self): return self.__x @x.setter 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' print(a.x)
Adam asked 2 years ago

What is the output of the following code?

class A:

    def __init__(self, value):

        self.x = value

    @property

    def x(self):

        return self.__x

    @x.setter

    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'

print(a.x)

 
a. ValueError
b. AttributeError
c. 7
d. George