class Item(object): item_name="" item_code="" item_price="" discount="" tax="" def __init__(self,n,c,p): self.item_name=n self.item_code=c self.item_price=p return def set_discount(self,d): self.discount=d return def get_discount(self): return self.discount def set_tax(self,t): self.tax=t return def get_tax(self): return self.tax def totalamount(self): st=600 return st def profile(self): print self.item_name print self.item_code print self.item_price return class product(Item): cat="" def __init__(self,category,n,c,p): super(product,self).__init__(n,c,p); self.cat = category return def __str__(self): p= super(product,self).profile() p+= self.cat return p s=product("mobile","samsung grand2","samnt3",24000) s.set_discount(4) s.set_tax(2) print s
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question