Object-Oriented Programming System presentation

PavanKumarPathipati 21 views 19 slides Oct 20, 2024
Slide 1
Slide 1 of 19
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19

About This Presentation

OOPS stands for Object-Oriented Programming System or Object-Oriented Programming Structure. It's a programming paradigm that organizes code into objects that contain data and behavior.


Slide Content

Object Oriented
Programming
- Python

Agenda
Python
•Introduction
•What is Class
•Inheritance and types
•Polymorphism
•Abstraction
•Encapsulation



2

Introduction
The main concept of OOPs is to bind the data and
the functions that work on that together as a
single unit so that no other part of the code can
access this data.
Python Class
A class is a collection of objects. A class contains the
blueprints or the prototype from which the objects are being
created.
python
3

Class
Syntax of Class:
class ClassName:
# Statement-1
.
# Statement-N
•Classes are created by keyword class.
•Attributes are the variables that belong to a class.
•Attributes are always public and can be accessed using the dot (.) operator.

python
4
Eg: class Dog:
sound = "bark"
…....

Object
•The object is an entity that has a state and behavior associated with it.
• It may be any real-world object like a mouse, keyboard, chair, table, pen, etc.
Integers, strings, floating-point numbers, even arrays, and dictionaries, are all
objects.
•More specifically, any single integer or any single string is an object.
•The number 12 is an object, the string “Hello, world” is an object

python
5

Object
Object Consists of:
•State
•Behavior
•Identity
Example:
•The identity can be considered as the name of the dog.
•State or Attributes can be considered as the breed, age, or color of the dog.
•The behavior can be considered as to whether the dog is eating or sleeping.



python
6

Constructors and Destructors
Constructors
• Used for instantiating an object.
•The task of constructors is to initialize(assign values)
to the data members of the class when an object of
the class is created.
•In Python the __init__() method is called the
constructor and is always called when an object is
created.
Syntax of constructor declaration :
def __init__(self):
# body of the constructor
Types:
Default Parameterized constructor

Destructors
•Destructors are called when an object gets destroyed.
• In Python, destructors are not needed as much as in C++ because
Python has a garbage collector that handles memory management
automatically.
•The __del__() method is a known as a destructor method in Python.
It is called when all references to the object have been deleted i.e
when an object is garbage collected.
Syntax of destructor declaration :
def __del__(self):
# body of destructor

7

Oops Concepts
•Inheritance
•Polymorphism
•Abstraction
•Encapsulation
Python
8

Inheritance
Inheritance is defined as the mechanism of inheriting
the properties of the base class to the child class
The Parent class is the class which provides features
to another class. The parent class is also known
as Base class or Superclass.
The Child class is the class which receives features
from another class. The child class is also known as
the Derived Class or Subclass.


Python
9
Types of Inheritance
•Single
•Multiple
•Multilevel
•Hierarchical
•Hybrid

Single Inheritance
Single inheritance enables a derived class to
inherit properties from a single parent class.
10
PYTHON

Multiple Inheritance
•A class can be derived from more than one base class
this type of inheritance is called multiple inheritances.
• In multiple inheritances, all the features of the base
classes are inherited into the derived class.
11
PYTHON

Multilevel Inheritance
•In multilevel inheritance, features of the base class
and the derived class are further inherited into the
new derived class.
• This is similar to a relationship representing a
child and a grandfather.
12
PYTHON

Hierarchical Inheritance
•When more than one derived class are created from a
single base this type of inheritance is called hierarchical
inheritance.
•In this program, we have a parent (base) class and two or
more child(derived) classes.
13
PYTHON

Hybrid Inheritance
•Inheritance consisting of multiple
types of inheritance is called
hybrid inheritance.
14
PYTHON

Polymorphism
•Polymorphism simply means having many forms.
•This code demonstrates the concept of inheritance
and method overriding in Python classes.
• It shows how subclasses can override methods
defined in their parent class to provide specific
behavior while still inheriting other methods from
the parent class.
15
PYTHON

Encapsulation

•Encapsulation is a mechanism of wrapping the data (variables) and
code acting on the data (methods) together as a single unit.
•Access modifiers in the concept of Encapsulation and data hiding.
•Public: Accessible from inside or outside the class.
•Private: Accessible only inside class. Define a private member by
prefixing the member name with two underscores. Eg: __age
•Protected: Accessible. from inside the class and its sub-class.
Define a protected member by prefixing the member name with an
underscore Eg: _points
16
Access Modifiers
•Public
•Private
•Protected

Abstraction

•It hides unnecessary code details from the user.
• Also, when we do not want to give out sensitive
parts of our code implementation and this is where
data abstraction came.
17
Python

SUMMARY
Python
•These are various Object Oriented Programming
concepts in Python.
•Online Reference:
W3schools
GeeksforGeeks

18

Thank You
Any Queries ??