Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyProperty
#Python 2.7.17 #PyProperty #this code is created by Rezaul Hoque on January 03,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; class Fruit: def __init__(self, fruit, price,qty): self.fruit = fruit self.set_price(price) self.set_qty(qty) def set_price(self, price): if price <= 0: raise ValueError('Price must be positive') self._price = price def set_qty(self,qty): if qty<= 0: raise ValueError('Quantity must be positive') self._qty = qty def get_price(self): return self._price def get_qty(self): return self._qty a = Fruit('Guava',10,1) print(a.fruit) print(a.get_price()) print(a.get_qty())
run
|
edit
|
history
|
help
0
pi1
runologist
codeacademy python tasks
python
Boauth
working with strings
e742c63f03ab602f2b38433ffc28b5145ba1332d
two sum
axsd
16