0% found this document useful (0 votes)
6 views21 pages

Object Oriented Programming Using Python: BY:-Nisreen Basher Alshagi

Uploaded by

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

Object Oriented Programming Using Python: BY:-Nisreen Basher Alshagi

Uploaded by

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

Object Oriented Programming

Using Python

Introduction
Different
What are
Object

BY:-Nisreen Basher Alshagi


Outline
✓ Introduction to Object Oriented Programming in Python
✓ Difference between Object-Oriented and Procedural
Oriented Programming
✓ What are Classes and Objects?
✓ Object-Oriented Programming methodologies:
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
Object Oriented Programming in Python

Object Oriented Programming is a way of


computer programming using the idea of

Introduction
“objects” to represents data and methods. It is
Different
Object
What are

also, an approach used for creating neat and


reusable code instead of a redundant one.
Difference between Object-Oriented and Procedural
Oriented Programming

Introduction
What are

Different
Object
What are Classes and Objects?
Class is a template of object
Object is a instance of a class

Example:

Introduction
Different
What are
Object
Creating an Object and Class in python:

Introduction
Different
What are
Object
Object-Oriented Programming methodologies:
❑ Encapsulation
• is one of the fundamentals of OOP.
• Simplifies and makes it easy to understand to use
an object without knowing the internals.
Encapsulation

Introduction
• Encapsulation provides us the mechanism of

Different
What are
Object
restricting the access to some of the object’s
components, this means that the internal
representation of an object can’t be seen from
outside of the object definition.
• Access to this data is typically achieved through
special methods: Getters and Setters.
Abstraction
Creating an Encapsulation in python:

Encapsulation

Object
What are
Different
Introduction
Abstraction
This property allows us to hide the details and
expose only the essential features of a concept
or object.

Example:

Encapsulation

Introduction
Inheritance

Abstraction

Different
What are
Object
CLASS CAR:
def get_speed(self):
return self.speed
Inheritance
in Programming , It generally means “inheriting or
transfer of characteristics from parent to child
class without any modification”. The new class is
Polymorphism

called the derived/child class and the one from

Abstraction
Inheritance

Encapsulation

Introduction
which it is derived is called a parent/base class.

Different
What are
Object
v
Single Inheritance

Single level inheritance enables a derived class to


inherit characteristics from a single parent class
Polymorphism

Abstraction
Inheritance

Encapsulation

Introduction
Different
What are
Object
v
Multilevel Inheritance
Multi-level inheritance enables a derived
class to inherit properties from an immediate
parent class which in turn inherits properties
from his parent class.
Polymorphism

Abstraction
Inheritance

Encapsulation

Introduction
Different
What are
Object
v
Polymorphism

v
Creating an Multilevel Inheritance in python:

Inheritance
Abstraction
Encapsulation

Object
What are
Different
Introduction
Hierarchical Inheritance

Hierarchical level inheritance enables more than


one derived class to inherit properties from a
parent class.
Polymorphism

Abstraction
Inheritance

Encapsulation

Introduction
Different
What are
Object
v
Polymorphism

v
Inheritance
Creating an Hierarchical Inheritance in python:

Abstraction
Encapsulation

Object
What are
Different
Introduction
Multiple Inheritance

Multiple level inheritance enables one derived class


to inherit properties from more than one base class.
Polymorphism

Abstraction
Inheritance

Encapsulation

Introduction
Different
What are
Object
v
Polymorphism
Creating an Multiple Inheritance in python:

v
Inheritance
Abstraction
Encapsulation

Object
What are
Different
Introduction
Polymorphism
It is one such OOP methodology where one task can
be performed in several different ways

overloading
Polymorphism

It lets you declare the same method multiple times

Polymorphism

Abstraction
Inheritance
with different argument lists.

Encapsulation

Introduction
Different
What are
Object
v
overriding
is a feature that allows us to use a function in the child
class that is already present in its parent class
Creating an overloading function in python:

overloading

Polymorphism
v
Inheritance
Abstraction
Encapsulation

Object
What are
Different
Introduction
ating an overriding function in python:

overriding

Polymorphism
v
Inheritance
Abstraction
Encapsulation

Object
What are
Different
Introduction

You might also like