Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyProperty
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 #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())
[
+
]
Show input
Absolute running time: 0.17 sec, cpu time: 0.02 sec, memory peak: 7 Mb, absolute service time: 0,22 sec
edit mode
|
history
|
discussion
Guava 10 1