What is it with this OOPs
Class : A blueprint/template Object : The physical instance
Python Object Oriented Programming
Objects in Python
Samsung
Motorola
Specific instances of Mobile data
type
Specific instances of integer data
type
Apple
Class in Python
Class is a user-defined data-type
Mobile
float
bool str
Int
Class
Classes
Class is a template/blue-print for real-world entities
Properties Behavior
• Color
• Cost
• Battery Life
• Make Calls
• Watch Videos
• Play Games
OOPS
Object-oriented programming (OOP) involves programming using
objects. An object represents an entity in the real-world that can be
distinctly identified.
An object consists of identity, state, and behavior.
• Identity: It gives a unique name to an object.
• State: It reflects the properties of an object.
• Behavior: It reflects the response of an object with other
objects.
Characteristics of OOPs
• OOPs uses a bottom-up approach.
• The program is divided into objects.
• OOPs is more secure than procedural languages.
Creating the first Class
Creating the ‘Phone’ class
Instantiating the ‘p1’ object
Invoking methods through
object
Main Memory
P1(Phone)
Creating a class and
init method acts as the constructor
__init__ is a method that is automatically
called when memory is allocated to a
new object.
For invoking in build parameter with object , self is
used .
P1= Employee(Kiran,34,22000,Male)
P2= Employee(Sruthi,37,34000,Female)
Kiran
34
22000
Male
Sruthi
37
34000
Female
Instantiating Object
Instantiating the ‘e1’ object
Invoking the
‘employee_details’
method
Inheritance in Python
With inheritance one class can derive the properties of another class
Man inheriting
features from his
father
Inheritance Example
Creating the base class
Instantiating the object for base class
Inheritance Example
Creating the child class
Instantiating the object for child class
Invoking the child class method
Over-riding init method
Over-riding init
method
Invoking show_details()
method from parent
class
Invoking
show_car_details()
method from child class
Super:
super() is a built-in function used in object-oriented programming to give you access to methods and properties of a parent or sibling class.
super() is a built-in
function used in object-
oriented programming
to give you access to
methods and
properties of a parent
or sibling class.
Types of Inheritance
Single Inheritance
Multiple Inheritance
Multi-level Inheritance
Hybrid Inheritance
Multiple Inheritance
Child
Parent 1 Parent 2
In multiple inheritance, the child inherits from more than 1 parent class
Multiple Inheritance in Python
Parent Class
One
Parent Class
Two
Child
Class
Multiple Inheritance in Python
Instantiating object of child class
Invoking methods
Multi-Level Inheritance
Parent
In multi-level Inheritance, we have Parent, child, grand-child relationship
Child
Grand-Child
Multi-Level Inheritance in Python
Parent Class
Child Class
Grand-Child Class
Multi-Level Inheritance in Python
Instantiating object of GrandChild class
Invoking class methods
Definitions :
Abstraction is the property by virtue of which only the essential details
are displayed to the user.
Encapsulation is a process of binding data members and member
functions into a single unit. Encapsulation hides the state of a structured
data object inside a class, preventing unauthorized access to an
unauthorized person.
Polymorphism is a Greek word that means many shaped. Polymorphism
is the ability of a message to be displayed in more than one form.
oops-in-python-240412044200-2d5c6552.pptx

oops-in-python-240412044200-2d5c6552.pptx

  • 2.
    What is itwith this OOPs Class : A blueprint/template Object : The physical instance
  • 3.
  • 4.
    Objects in Python Samsung Motorola Specificinstances of Mobile data type Specific instances of integer data type Apple
  • 5.
    Class in Python Classis a user-defined data-type Mobile float bool str Int
  • 6.
    Class Classes Class is atemplate/blue-print for real-world entities Properties Behavior • Color • Cost • Battery Life • Make Calls • Watch Videos • Play Games
  • 7.
    OOPS Object-oriented programming (OOP)involves programming using objects. An object represents an entity in the real-world that can be distinctly identified. An object consists of identity, state, and behavior. • Identity: It gives a unique name to an object. • State: It reflects the properties of an object. • Behavior: It reflects the response of an object with other objects.
  • 8.
    Characteristics of OOPs •OOPs uses a bottom-up approach. • The program is divided into objects. • OOPs is more secure than procedural languages.
  • 9.
    Creating the firstClass Creating the ‘Phone’ class Instantiating the ‘p1’ object Invoking methods through object Main Memory P1(Phone)
  • 10.
    Creating a classand init method acts as the constructor __init__ is a method that is automatically called when memory is allocated to a new object. For invoking in build parameter with object , self is used . P1= Employee(Kiran,34,22000,Male) P2= Employee(Sruthi,37,34000,Female) Kiran 34 22000 Male Sruthi 37 34000 Female
  • 11.
    Instantiating Object Instantiating the‘e1’ object Invoking the ‘employee_details’ method
  • 12.
    Inheritance in Python Withinheritance one class can derive the properties of another class Man inheriting features from his father
  • 13.
    Inheritance Example Creating thebase class Instantiating the object for base class
  • 14.
    Inheritance Example Creating thechild class Instantiating the object for child class Invoking the child class method
  • 15.
    Over-riding init method Over-ridinginit method Invoking show_details() method from parent class Invoking show_car_details() method from child class Super: super() is a built-in function used in object-oriented programming to give you access to methods and properties of a parent or sibling class. super() is a built-in function used in object- oriented programming to give you access to methods and properties of a parent or sibling class.
  • 16.
    Types of Inheritance SingleInheritance Multiple Inheritance Multi-level Inheritance Hybrid Inheritance
  • 17.
    Multiple Inheritance Child Parent 1Parent 2 In multiple inheritance, the child inherits from more than 1 parent class
  • 18.
    Multiple Inheritance inPython Parent Class One Parent Class Two Child Class
  • 19.
    Multiple Inheritance inPython Instantiating object of child class Invoking methods
  • 20.
    Multi-Level Inheritance Parent In multi-levelInheritance, we have Parent, child, grand-child relationship Child Grand-Child
  • 21.
    Multi-Level Inheritance inPython Parent Class Child Class Grand-Child Class
  • 22.
    Multi-Level Inheritance inPython Instantiating object of GrandChild class Invoking class methods
  • 23.
    Definitions : Abstraction isthe property by virtue of which only the essential details are displayed to the user. Encapsulation is a process of binding data members and member functions into a single unit. Encapsulation hides the state of a structured data object inside a class, preventing unauthorized access to an unauthorized person. Polymorphism is a Greek word that means many shaped. Polymorphism is the ability of a message to be displayed in more than one form.