Python OOPs Concepts:
Like Java and C++, Python is also based on OOPs Concept, i.e, Python is an object-oriented programming language which uses classes and objects for computations.
Advantages of Python being a Object Oriented Programming Language:
- Development and maintenance of Python codes is easier than the procedural programming.
- Python can easily solve the real world problems as it does not works on step by step instructions.
- Data in Python codes are secure due to its special feature of data hiding.
Principles of OOPs:
An object oriented programming is based on seven fundamental principles.
- Data Abstraction
Anything that has state and behavior can be termed as an Object, be it physical or logical. An Object is an entity mentioned in OOPs concept and is frequently found in Python codes.
A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods.
Method is similar to a function. It is just a name given to a function associated with an object. That is, in OOPs concept function is termed as Method. In Python, object of any type can have methods which is not necessarily unique to any class instance.
The property of acquiring all the properties and behaviors of the parent object by an object is termed as inheritance in OOPs. This is a unique feature in object oriented programming languages which facilitates reusability of the code of the parent class by the derived class.
OOPs is based on the principle of Polymorphism, which means, that one task can be performed in many ways.
OOPs restrict direct access to its methods and variables by encapsulating the code and data together.
OOPS Data Abstraction feature is used for hiding internal details and showing the functionality only.