class Pet: name = "" pType = "" age = 0 def setName(self, nameIn): self.name = nameIn def setType(self, typeIn): self.pType = typeIn def setAge(self, ageIn): self.age = ageIn def getName(self): return self.name def getType(self): return self.pType def getAge(self): return self.age def main(): petName = Pet() petName.setName(raw_input("\nWhat is your pet's name?: ")) petName.setType(raw_input("\nWhat type of pet is s/he?: ") ) petName.setAge(raw_input("\nHow old is your pet?: \n")) print petName.getName() print petName.getType() print str(petName.getAge()) 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