OOP involves creation of classes & objects, concept of OOP is to create reusable code.This concept is also known as DRY(Don't Repeat Yourself).
This type of programming requires much code to perform simple tasks,hence it is better to go for procedure based approach for simple tasks.
In Python, private, public and protected access specifiers are not available. Everything written in the class will come under public.
If we want to declare a variable as private we can use double underscores before the variable or function name(__var,__func
).
Some terminologies used in OOP.
class
--> class is simply the blueprint of the Object.
constructor
--> Constructor are special method which are called automatically when the object of the class is created.
constructors are used to initialise class level variables. It has no return type.
object
--> Object is simply a collection of variables and methods, that act on those methods.
An object is also called instance of a class and the process of creating object is called instantiation
methods
--> Functions created inside the class are known as methods
To dive deeper in OOP with Python checkout the Jupyter notebook.
Note: when we create a class, it is advised to have first letter as capital in the class name.