+1 vote
in Class 12 by kratos

How data encapsulation and data abstraction are implemented in Python, explain with an example.

1 Answer

+2 votes
by kratos
 
Best answer

Abstraction and Encapsulation are complementary concepts. Through encapsulation only we are able to enclose the components of the object into a single unit and separate the private and public members. It is through abstraction that only the essential behaviors of the objects are made visible to the outside world.

So, we can say that encapsulation is the way to implement data abstraction. For example in class Student, only the essential information like roll no, name, date_of_birth, course, etc. of the student will be visible. The secret information like calculation of grades, allotment of examiners etc. will be hidden.

...