Skip to content

Latest commit

聽

History

History
29 lines (17 loc) 路 717 Bytes

File metadata and controls

29 lines (17 loc) 路 717 Bytes

馃悕 Python OOP: Encapsulation with Private Members

馃幆 AIM

To implement Encapsulation in Python by defining a class Rectangle with private member variables __length and __breadth.


馃 ALGORITHM

  1. Define the Class:

    • Create a class Rectangle with two private attributes: __length and __breadth.
  2. Initialize Variables:

    • Use the __init__() constructor to set initial values for __length and __breadth.
  3. Print Values:

    • Display the private variables from within the class to demonstrate access.
  4. Instantiate the Object:

    • Create an object of the Rectangle class to trigger the constructor.

馃捇 Program

Output

Result