DATA ABSTRACTION IN PYTHON

GOCOURSE



Data Abstraction  

  • In Python, Data Abstraction hiding internal details and showing functionality is known as Data Abstraction. 
  • Data abstraction  or Information hiding refers to providing only essential to the outside world and hiding their background details. A class that comprises at least one abstraction method is known as the abstraction class. 
  • Abstraction class can be acquired by the subclass and the unique method gets its definition in the subclass. 
  • An abstraction class can be helpful when we are planning huge capacities. An abstraction class is additionally useful to give the standard interface to various executions of parts.

Program:


  import abc
  from abc import ABC, abstractmethod
 
  class DEMO(ABC):
      def func(self):
          print("Abstract  Class")
 
  class DEMO2(DEMO):
      def func(self):
          super().func()
          print("subclass ")
 
  # object creating
  r = DEMO2()
  r.func()


Output:


  Abstract  Class
  subclass
 





More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send