<jupyter_start><jupyter_text>All classes have a common super-class: "object"<jupyter_code># base class
class Animal:
    def __init__(self, kind): 
        self.kind   = kind
        self.tricks = []
    def speak(self): pass
# inherited class Cat
class Cat(Animal):
    def __init__(self, name):
        super().__init__("feline")    
        self.name = name
    def speak(self):
        return "miau"
# inherited class Dog
class Dog(Animal):
    def __init__(self, name):
        super().__init__("canine")
        self.name = name
    def add_trick(self, trick):
        self.tricks.append(trick)
    def speak(self):
        return "ham"

# demonstrate polymorphism
def test(a: Animal):
    print(a.name, "say:", a.speak())

# create two objects
d = Dog("Buddy")
c = Cat("Flufy")
# call methods 
d.add_trick('roll over')
d.add_trick('play dead')
# print objects
print(d.kind, d.name, d.tricks)
print(c.kind, c.name, c.tricks)
# test polimorphism
test(d)
test(c)<jupyter_output>canine Buddy ['roll over', 'play dead']
<NAME> [] say:
Buddy say: ham
Flufy say: miau
{'fraction_non_alphanumeric': 0.1415182755388941, 'fraction_numerical': 0.0, 'mean_word_length': 3.306451612903226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '565685', 'license': 'MIT', 'n_tokens_mistral': 390, 'n_tokens_neox': 378, 'n_words': 100, 'path': 'inheritance.ipynb', 'repo_name': 'sage-code/python', 'size': '1073'}