There are three widely used programming paradigms are: procedural programming, functional programming, and object-oriented programming. Python supports all three programming paradigms.
Object-oriented programming
Object-oriented programming (OOP) is a programming paradigm that uses objects and their interactions to design applications and computer programs.
OOPs is based on four concepts:
Object and Classes
OOPs Concepts
1. Abstraction
Abstraction is used to hide internal details and show only functionalities to other intended users. Here, by other intended user, we mean another software application, or another class, or other client who will be the end users of the program.
Abstracting something means to give names to things, so that the name captures the core of what a function or a whole program does.
2. Encapsulation
Abstraction: Suppose you are going to an ATM to withdraw money. You simply insert your card and click some buttons and get the money. You don’t know what is happening internally on press of these buttons. Basically you are hiding unnecessary information from user. So, abstraction is a method to hide internal functionalities from user.
Encapsulation: Suppose there is a tree. Now a tree can have its components like root, stem, branches, leaves, flowers and fruits. It has some functionalities like Photosynthesis. But in a single unit we call it a tree. In same way encapsulation is a characteristic to bind data members and functions in single unit.
3. Polymorphism
The polymorphism is the process of using an operator or function in different ways for different data input.
4. Inheritance
The inheritance is a way to form new classes using classes that have already been defined.
Inheritance is a way to reuse once written code again and again. The class which is inherited is called the Base class & the class which inherits is called the Derived class. They are also called parent and child class.
So when, a derived class inherits a base class, the derived class can use all the methods (functions) which are defined in base class, hence making code reusable.