0
Properties
How is answer ? Define a decorator that would be used to add a setter to the property egg.
5 Answers
+ 3
class SomeClass:
def __init__(self):
self._egg = 0
# this is a getter
@property
def egg(self):
return self._egg
# this is the setter
@egg.setter
def egg(self, value):
self._egg = value
+ 3
@egg.setter
0
Using the property decorator
0
Using the property decorator
0
class Number:
def __init__(self, num):
self.value = num
@property
def isEven(self):
if self.value % 2==0:
return True
else:
return False
x = Number(int(input()))
print(x.isEven)