class Pet(object): def __init__(self, name, animal_type, age): self.__name = name self.__animal_type = animal_type self.__age = age def set_name(self, name): self.__name = name def set_type(self, animal_type): self.__animal_type = animal_type def set_age(self, age): self.__age = age def get_name(self): return self.__name def get_animal_type(self): return self.__animal_type def get_age(self): return self.__age def main(): name = raw_input("Enter the name of your pet. ") animal_type = raw_input("What kind of animal is {}? ".format(name)) age = int(input("How old is {}? ".format(name))) pets = Pet(name, animal_type, age) print("Thank you. This will be added to our records. ") print("Here is the information you have entered for your {} {}: ".format(animal_type, name)) print("Pet Name: {}".format(pets.get_name())) print("Animal Type: {}".format(pets.get_animal_type())) print("Age: {}".format(pets.get_age())) 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