image
image
image

Wrap-Up

image

Python supports different programming approaches as it is a multi-paradigm. An object in Python has an attribute and behavior. From a class, we can construct objects by simply making an instance of the class. The class_name() operator creates an object by assigning the object to the empty method. The keyword def is used to define a class in Python. The first string in a Python class is used to describe the class even though it is not always needed. When a method is defined in both the base class and the derived class, the method in the child class/derived class will override the parent/base class. In the above example, _init_() method in Rectangle class will override the _init_() in Shape class.

Inbuilt classes can use operators and the same operators will behave differently with different types. An example is the + that depending on context will perform concatenation of two strings, arithmetic addition on numbers, or merge lists. Operating overloading is an OOP feature that allows assigning varying meaning to an operator subject to context.From a class, we can construct objects by simply making an instance of the class. The class_name() operator creates an object by assigning the object to the empty method.

The _init_() function is a special function and gets called whenever a new object of the corresponding class is instantiated. Functions defined within a body of the class are known as methods and are basic functions. Methods define the behaviors of an object. In Python, polymorphism refers to the ability to use a shared interface for several data types. An illustration is a program that has defined two classes Tilapia and Shark all of which share the method jump() even though they have different functions. By creating common interface jumping_test() we allowed polymorphism in the program above. We then passed objects bonny and biggy in the  jumping_test( ) function.