Answer
Making data fields private protects data and makes the class easy to maintain.
Work Step by Step
To prevent direct modifications of data fields, don’t let the client directly access data fields. This is known as data hiding.
This can be done by defining private data fields. In Python, the private data fields are defined with two leading underscores.
You can also define a private method named with two leading underscores.
Private data fields and methods can be accessed within a class, but they cannot be accessed outside the class.
To make a data field accessible for the client, provide a get method to return its value.
To enable a data field to be modified, provide a set method to set a new value.