0% found this document useful (0 votes)
36 views17 pages

Abstraction Python

Abstraction in Python is a key principle of object-oriented programming that involves exposing only relevant data while hiding implementation details, thereby reducing complexity and enhancing development efficiency. There are two types of abstraction: data abstraction, which conceals original data through data structures, and process abstraction, which hides implementation details of processes. Abstract classes and interfaces are used to define abstract methods that must be implemented by child classes, with Python's abc module facilitating this functionality.

Uploaded by

fall3210060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views17 pages

Abstraction Python

Abstraction in Python is a key principle of object-oriented programming that involves exposing only relevant data while hiding implementation details, thereby reducing complexity and enhancing development efficiency. There are two types of abstraction: data abstraction, which conceals original data through data structures, and process abstraction, which hides implementation details of processes. Abstract classes and interfaces are used to define abstract methods that must be implemented by child classes, with Python's abc module facilitating this functionality.

Uploaded by

fall3210060
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Abstraction

Abstraction in Python

• Abstraction is one of the important principles of object-


oriented programming.

• It refers to a programming approach by which only the


relevant data about an object is exposed, hiding all the
other details.

• This approach helps in reducing the complexity and


increasing the efficiency of application development.
Types of Python Abstraction

• There are two types of abstraction. One is data


abstraction, wherein the original data entity is hidden via
a data structure that can internally work through the
hidden data entities.

• Another type is called process abstraction. It refers to


hiding the underlying implementation details of a process.
Abstraction ??

• Did you learn Abstraction in Previous Programming


Language .

• If Yes _____OK .
• If No_______OK_OK.

• First we will learn that after that we will learn According to


Object Oriented Programming.
Abstraction

• Abstraction is the process of hiding the implementation


details from the user only the highlighted set of services
provided to the user.

• EX: Call  Green  Red


• When ever someone calling you have two choices either of
them.
• You know what is the impact of these two services buttons
but the internal implementation and code is hidden from
you .
Python Modules

User can Access services only


Backend/Internal Implementation Internal implementation hide

first.py second.py
add() sub() main.py
{ { add()
Sub()
} }
Python Modules Backend (first.py,
second.py)

first.py secon.py
Python Modules Services (Add, Sub)

main.py Output
Abstraction in OOP(python)

Abstraction

Abstract
Interface
Class
Abstract Class
• Abstract class is a class that contain one or more abstract method is
called Abstract class.

• An object of an Abstract class can not be created.

• Python provides abc module to work with Abstraction.

• We use @abstractmethod decorator to define abstract method.

• Abstraction used when Action is Common and Implementation is


Different.
Syntax
Interface

• Interface is nothing but abstract class which contain only abstract


method but does not have any normal method.

• We can not create object of interface.

• We use interface when action is same and implementation is


different.

• All child class should be inherit abstract method to override them.


Syntax
Example
Example
Example

You might also like