# This program creates a pet class with data attributes for the type of animal, # the name of the pet and the age of the pet. It also contains methods to get and # set the values of the data attributes. Class Pet: def __init__(self, petType, name, age): self.__petType = petType self.__name = name self.__age = age def set_name(self, name): self.__name = name def set_petType(self, petType): self.__petType = petType def set_age(self, age): self.__age = age def get_name(self, name): return self.__name def get_petType(self, petType): return self.__petType def get_age(self, age): return self.__age
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