Abstract Classes and Methods
Abstract class:
class Animal:
def __init__(self, name):
self.animal_name = name
def eat(self):
# raise is used to throw error
raise NotImplementedError("Child class should be implementing this")
class Monkey(Animal):
def eat(self):
print("Monkey eating bananas...")
class Bird(Animal):
def eat(self):
print("Bird eating seeds...")
def fly(self):
print("Bird soaring high...")
my_monkey = Monkey("jojo")
my_monkey() # Will print monkey eating bananasLast updated