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)

QuestionsCategory: Python 3What 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)
admin Staff asked 3 years ago

Answer: ValueError