Question OOP-ENC-0018
HardWhat is the output of this code?
class Item:
def __init__(self):
self._price = 0
@property
def price(self):
return self._price
@price.setter
def price(self, value):
if value < 0:
raise ValueError
self._price = value
i = Item()
try:
i.price = -10
print("Rs.", i.price)
except ValueError:
print("Invalid")
- A.
Invalid
- B.
None
- C.
Sign up free to see the answer and a step-by-step explanation.