Encapsulation:-
- Encapsulation is a important concept of object oriented programming language.
- In encapsulation methodology we can restrict access to methods and variables.
- To prevent the data access of the class from out side or same class, is known as encapsulation.
- In python ,we denote private attributes using prefix underscore(single(_) or double(__)).
- It is used to hide the entire class data from the outside source.
Benefits and needs of Encapsulation in python:-
- Encapsulation concepts not only ensure better data flow but also protects the data from the outside sources.
- Encapsulation is helpful to achieving well -defined interaction in each applications.
- Encapsulation helps to secure the python applications.
- Encapsulation ensures the data security and avoids the access the data accidentally.
Python allows us to access the method and variables from the outside the class as given below:-