0

Properties

How is answer ? Define a decorator that would be used to add a setter to the property egg.

9th Jun 2018, 7:27 PM
Hubert StrumiƄski
Hubert StrumiƄski - avatar
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
9th Jun 2018, 7:35 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 3
@egg.setter
7th Dec 2020, 2:40 PM
Turikumana Isaie
Turikumana Isaie - avatar
0
Using the property decorator
13th Nov 2019, 8:50 PM
Hope Yates
Hope Yates - avatar
0
Using the property decorator
28th Jan 2020, 6:44 AM
GOVINDHARAJPERUMAL R
GOVINDHARAJPERUMAL R - avatar
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)
25th May 2022, 1:02 PM
Farah