To implement Encapsulation in Python by defining a class Rectangle with private member variables __length and __breadth.
-
Define the Class:
- Create a class
Rectanglewith two private attributes:__lengthand__breadth.
- Create a class
-
Initialize Variables:
- Use the
__init__()constructor to set initial values for__lengthand__breadth.
- Use the
-
Print Values:
- Display the private variables from within the class to demonstrate access.
-
Instantiate the Object:
- Create an object of the
Rectangleclass to trigger the constructor.
- Create an object of the