In python, encapsulation is a process of binding the data members such as variables, properties, etc., and member functions into a single unit. The perfect example for encapsulation is class because it will wrap all the variables, functions, etc., into a single entity.
In python, encapsulation is helpful to prevent the accidental modification of data. For example, the class that you will create with required variables and functions will not allow you to modify the class members directly. Instead, you need to create an object to access or change those class members.
Following is the example of implementing the encapsulation in python.
The above python encapsulation example will return the result as shown below.
If required, you can also implement the access level restrictions on encapsulated class members using access modifiers in python based on your requirements.