example class dogclass attribute species "animalinstance attribute def __init__(selfnameage)self name name self age age instantiate the parrot class obj dog("blu" obj dog("woo" access the class attributes print("obj is {}format(dog species)print("obj is also {}format(dog species)access the instance attributes print("{is {years oldformatobj nameobj age)print("{is {years oldformatobj nameobj age)in the above examplewe define new class called dog it has function__init__(to initialize the variables inheritance in python object-oriented programming creates reusable patterns of code to curtail redundancy in development projects one way that object-oriented programming achieves recyclable code is through inheritance when one subclass can leverage code from another base class inheritance allows you to acquire the properties to base new class from an existing one by doing sothe new child class automatically gets all of the methods and attributes of the existing parent class in this wayyou can say the child class inherits the attributes of its parent class inheritance is way to form new classes using class that is already defined it is way of arranging objects in hierarchy from the most general to the most specific if we think of inheritance in terms of biologywe can think of child inheriting certain traits from their parent that isa child can inherit parent' height or eye color children also may share the same last name with their parents classes called child classes or subclasses inherit methods and variables from parent classes or base classes page