class Container: Size = 0 Shape = "" Color = "" Weight = 0 Materials = "" def __init__(self, _materials, _size, _shape, _color, _weight): self.Size = _size self.Shape = _shape self.Color = _color self.Weight = _weight self.Materials = _materials def Smash(): print "BANG" class Cup(Container): liquid = "" def __init__(self,_liquid,_materials, _size, _shape, _color, _weight): super(Cup.__class__, self).__init__(_materials, _size, _shape, _color, _weight) self.liquid = _liquid def pureOut(self): while self.Weight < 0: print self.Weight self.Weight-=0.1 def main(): GlassCup = Cup("Milk","Glass", "Small", "Round", "Red", 5.2) BigBox = Container("Cardboard","Big","Square","Black", 1) GlassCup.PureOut() GlassCup.Smash() BigBox.Smash() #BigBox.PureOut() if __name__ == "__main__": main()
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