Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyPropertyDecorator
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#Python 2.7.17 #PyPropertyDecorator #this code is created by Rezaul Hoque on January 04,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.price = price self.qty=qty @property def price(self): return self.price # price=property(fget=get_price,fset=set_price) @property def qty(self): return self.qty # qty=property(fget=get_qty,fset=set_qty) @price.setter def set_price(self, price): if price <= 0: raise ValueError('Price must be positive') self.price = price @qty.setter def set_qty(self,qty): if qty<= 0: raise ValueError('Quantity must be positive') self.qty = qty a = Fruit('Guava',10,1) print(a.fruit) print(a.price) print(a.qty)
[
+
]
Show input
Absolute running time: 0.18 sec, cpu time: 0.03 sec, memory peak: 7 Mb, absolute service time: 0,26 sec
edit mode
|
history
|
discussion
Guava 10 1