SlideShare une entreprise Scribd logo
1  sur  33
WEBINAR ON PYTHON
- Jyoti Shukla (SME)
AGENDA
 Object-Oriented Programming in Python
 Numpy
 Pandas
BACKGROUND
 Procedure Oriented Programming
 OOPS concept
 Features of OOP
 Class
 Object
 Encapsulation
 Inheritance
 Polymorphism
 Abstraction
PROCEDURE ORIENTED PROGRAMMING
 Procedural programming uses a list of instructions
to perform computations step by step.
 It works on sequential instructions divided into small
parts called functions or procedures.
 It is not easy to maintain the codes when the project
becomes lengthy.
 Testing consumes a lot of time for enterprise
projects.
 Procedural languages do not provide a proper way
for data hiding, so it becomes less secure.
OBJECT-ORIENTED PROGRAMMING (OOP)
 Object-oriented programming (OOP) is a
programming paradigm based on the concept of
"objects", which can contain data member and
code.
 Data member is in the form of fields (often known as
attributes or properties), and Code, is in the form of
methods (relate it to behaviors or functions).
FEATURES OF OOPS
OOP
Object
Class
Encapsula
tion
Data
Abstractio
n
Inheritanc
e
Polymorp
hism
WHAT IS CLASS..?
 A class can be defined as a template/ blueprint that
describes the state and behavior of an object of its
type.
 A class contain fields and methods to describe the
state and behaviour of an object respectively.
Methods are the members of a class that alter the
state of an object by performing business logics.
REPRESENTATION OF A CLASS
CLASS DEFINITION
WHAT IS OBJECT?
 Objects are the basic run-time real entities in an object-
oriented system.
 They may represent a person, a place, a bank account,
a table of data or any item that the program must
handle.
 An object has two characteristics: Attributes & Behavior.
 Classes are just a logical representation whereas
Objects are physical representation.
 Objects upon initialization are loaded in memory.
 Syntax: reference variable=classname()
 For Example: s1 = Student()
VARIABLES IN CLASSES
Data/Fields/Attributes/Properties can be represented
by a variable. A variable by its definition means
something that can be changed.
Types of variable.
• instance (scope: object)
• static (scope: class)
• local(scope: method)
INSTANCE VARIABLES
 An instance variable of an object is a piece of
information attached to an instance (object).
 Instance variables are defined inside the instance
method and constructor by using "self" keyword.
 Example: studentId, firstname, lastname etc.
 An object can usually have many instance
variables, of many different types.
 Each object is given its own private space(Memory)
to hold its instance variable.
 Assigning a new value to an instance variable of
one object does not affect the instance variables of
any other object.
METHOD IN CLASSES
Types of Methods:
 instance Method
 class method
 static method
INSTANCE METHODS
 When we define objects, we usually have an idea of
what we want to do with them.
 I'm dealing with Person objects in an employee
database... I should be able to ask each Person
object their name, weight, and age.
 An action that involves a single object is usually
implemented as a special kind of
function/subroutine attached to that object's class,
called an instance method (or, more commonly, just
a method).
__INIT__() METHOD
 The __init__() method is the constructor and is
always called when an object is created.
 Constructor is a special type of method which is
used to initialize the instance variables of the class.
 Syntax of constructor declaration.
def __init__(self):
#body of constructor
 This method can take any number of
arguments. However, the first argument "self" in the
definition is special.
SELF
 The first argument of instance method and
constructor is a reference to the current instance of
the class.
 Similar to the keyword "this" in Java, C++ etc.
 You do not give a value for this parameter(self)
when you call the method, Python will provide it
automatically.
ENCAPSULATION
 Encapsulation is used to restrict access to methods
and variables. In encapsulation, code and data are
wrapped together within a single unit from being
modified by accident.
 It can be achieved by: private members of class
 __variable
 __method
 Access to this data is typically only achieved
through special methods: Getters and Setters By
using solely get() and set() methods
PRIVATE DATA
 Variable names starting with two underscore
characters cannot be accessed from outside of the
class. At least not directly, but they can be
accessed through public members of class.
class Encapsulation(object):
def __init__(self, a, b, c):
self.public = a
self.__private=b
EXAMPLE
INHERITANCE
 Inheritance is the capability of one class to derive or
inherit the properties from some another class.
 Benefits of inheritance are:
 It represents real-world relationships well.
 It provides reusability of a code. We don’t have to write
the same code again and again. Also, it allows us to add
more features to a class without modifying it.
 It is transitive in nature, which means that if class B
inherits from another class A, then all the subclasses of
B would automatically inherit from class A.
Syntax:
class derivedclass(base class):
TYPES OF INHERITANCE
1. Single inheritance
2. Multiple inheritance
3. Multilevel Inheritance
4. Hybrid Inheritance
5. Hierarchical Inheritance
SINGLE INHERITANCE
When a child class inherits from only one
parent class, it is called as single
inheritance.
MULTIPLE INHERITANCE
 When a child class inherits from multiple parent
classes.
 Python supports multiple inheritance. We specify
all parent classes as comma separated list in
bracket.
MULTILEVEL INHERITANCE
Multi-level inheritance is achieved when a derived
class inherits another derived class.
HYBRID INHERITANCE
 This form combines more than one form of
inheritance. Basically, it is a blend of more than one
type of inheritance
POLYMORPHISM
 Polymorphism is ability to use a common interface
for multiple forms (data types).
 It refers to the use of a single type entity (method,
operator or object) to represent different types in
different scenarios.
POLYMORPHISM CONTD.
We can implement polymorphism by
 Overloading
operator
method
constructor
 Overriding
method
constructor
POLYMORPHISM CONTD.
 Method Overloading, a way to create multiple
methods with the same name but different
arguments.
 It is achieved by passing different number
of arguments or by passing different types of
arguments.
POLYMORPHISM CONTD.
 Method Overriding: It allows us to change the
implementation of function in the child class which
is defined in the parent class.
 Following conditions must be met for overriding
a function:
Inheritance should be implemented. Method overriding
cannot be done within a class. We need to derive a child
class from a parent class.
The function that is redefined in the child class should
have the same definition/ signature as in the parent
class i.e. same number of parameters.
DATA ABSTRACTION
 It is the process of hiding the real implementation of an
application from the user and emphasizing only on
usage of it.
 E.g. when you use mobile, we need not know how
pressing a key changes the volume level. We just need
to know that pressing up button increases the volume
and the down button reduces the volume.
Why Do We Need Abstraction?
Through the process of abstraction, a programmer can
hide all the irrelevant data/process of an application in
order to reduce complexity, provide security and
increase the efficiency.
DATA ABSTRACTION CONTD.
Abstract class
 Abstract class are the classes which contain one or
more abstract method.
Abstract Method
 Abstract Methods are the methods which only
have declaration and no definition.
IMPLEMENTATION
Thank You

Contenu connexe

Tendances

Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing fileskeeeerty
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programmingSrinivas Narasegouda
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in pythonnitamhaske
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in PythonSujith Kumar
 
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++Arpita Patel
 

Tendances (20)

OOP C++
OOP C++OOP C++
OOP C++
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
Python Modules
Python ModulesPython Modules
Python Modules
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Oop java
Oop javaOop java
Oop java
 
Types of methods in python
Types of methods in pythonTypes of methods in python
Types of methods in python
 
Overloading vs Overriding.pptx
Overloading vs Overriding.pptxOverloading vs Overriding.pptx
Overloading vs Overriding.pptx
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Advance OOP concepts in Python
Advance OOP concepts in PythonAdvance OOP concepts in Python
Advance OOP concepts in Python
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
 
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
 

Similaire à object oriented programming(PYTHON)

Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHPVibrant Technologies & Computers
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascriptUsman Mehmood
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptxRaazIndia
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxKunalYadav65140
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)smumbahelp
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS ConceptRicha Gupta
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingsangumanikesh
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rdConnex
 
Java for android developers
Java for android developersJava for android developers
Java for android developersAly Abdelkareem
 

Similaire à object oriented programming(PYTHON) (20)

Python advance
Python advancePython advance
Python advance
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
UNIT III (8).pptx
UNIT III (8).pptxUNIT III (8).pptx
UNIT III (8).pptx
 
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
 
Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)Mcs 024 assignment solution (2020-21)
Mcs 024 assignment solution (2020-21)
 
Only oop
Only oopOnly oop
Only oop
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -3 BY ADI.pdf
JAVA PPT -3 BY ADI.pdfJAVA PPT -3 BY ADI.pdf
JAVA PPT -3 BY ADI.pdf
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overloding
 
java part 1 computer science.pptx
java part 1 computer science.pptxjava part 1 computer science.pptx
java part 1 computer science.pptx
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
Java for android developers
Java for android developersJava for android developers
Java for android developers
 

Dernier

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Dernier (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

object oriented programming(PYTHON)

  • 1. WEBINAR ON PYTHON - Jyoti Shukla (SME)
  • 2. AGENDA  Object-Oriented Programming in Python  Numpy  Pandas
  • 3. BACKGROUND  Procedure Oriented Programming  OOPS concept  Features of OOP  Class  Object  Encapsulation  Inheritance  Polymorphism  Abstraction
  • 4. PROCEDURE ORIENTED PROGRAMMING  Procedural programming uses a list of instructions to perform computations step by step.  It works on sequential instructions divided into small parts called functions or procedures.  It is not easy to maintain the codes when the project becomes lengthy.  Testing consumes a lot of time for enterprise projects.  Procedural languages do not provide a proper way for data hiding, so it becomes less secure.
  • 5. OBJECT-ORIENTED PROGRAMMING (OOP)  Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data member and code.  Data member is in the form of fields (often known as attributes or properties), and Code, is in the form of methods (relate it to behaviors or functions).
  • 7. WHAT IS CLASS..?  A class can be defined as a template/ blueprint that describes the state and behavior of an object of its type.  A class contain fields and methods to describe the state and behaviour of an object respectively. Methods are the members of a class that alter the state of an object by performing business logics.
  • 10. WHAT IS OBJECT?  Objects are the basic run-time real entities in an object- oriented system.  They may represent a person, a place, a bank account, a table of data or any item that the program must handle.  An object has two characteristics: Attributes & Behavior.  Classes are just a logical representation whereas Objects are physical representation.  Objects upon initialization are loaded in memory.  Syntax: reference variable=classname()  For Example: s1 = Student()
  • 11. VARIABLES IN CLASSES Data/Fields/Attributes/Properties can be represented by a variable. A variable by its definition means something that can be changed. Types of variable. • instance (scope: object) • static (scope: class) • local(scope: method)
  • 12. INSTANCE VARIABLES  An instance variable of an object is a piece of information attached to an instance (object).  Instance variables are defined inside the instance method and constructor by using "self" keyword.  Example: studentId, firstname, lastname etc.  An object can usually have many instance variables, of many different types.  Each object is given its own private space(Memory) to hold its instance variable.  Assigning a new value to an instance variable of one object does not affect the instance variables of any other object.
  • 13. METHOD IN CLASSES Types of Methods:  instance Method  class method  static method
  • 14. INSTANCE METHODS  When we define objects, we usually have an idea of what we want to do with them.  I'm dealing with Person objects in an employee database... I should be able to ask each Person object their name, weight, and age.  An action that involves a single object is usually implemented as a special kind of function/subroutine attached to that object's class, called an instance method (or, more commonly, just a method).
  • 15. __INIT__() METHOD  The __init__() method is the constructor and is always called when an object is created.  Constructor is a special type of method which is used to initialize the instance variables of the class.  Syntax of constructor declaration. def __init__(self): #body of constructor  This method can take any number of arguments. However, the first argument "self" in the definition is special.
  • 16. SELF  The first argument of instance method and constructor is a reference to the current instance of the class.  Similar to the keyword "this" in Java, C++ etc.  You do not give a value for this parameter(self) when you call the method, Python will provide it automatically.
  • 17. ENCAPSULATION  Encapsulation is used to restrict access to methods and variables. In encapsulation, code and data are wrapped together within a single unit from being modified by accident.  It can be achieved by: private members of class  __variable  __method  Access to this data is typically only achieved through special methods: Getters and Setters By using solely get() and set() methods
  • 18. PRIVATE DATA  Variable names starting with two underscore characters cannot be accessed from outside of the class. At least not directly, but they can be accessed through public members of class. class Encapsulation(object): def __init__(self, a, b, c): self.public = a self.__private=b
  • 20. INHERITANCE  Inheritance is the capability of one class to derive or inherit the properties from some another class.  Benefits of inheritance are:  It represents real-world relationships well.  It provides reusability of a code. We don’t have to write the same code again and again. Also, it allows us to add more features to a class without modifying it.  It is transitive in nature, which means that if class B inherits from another class A, then all the subclasses of B would automatically inherit from class A. Syntax: class derivedclass(base class):
  • 21. TYPES OF INHERITANCE 1. Single inheritance 2. Multiple inheritance 3. Multilevel Inheritance 4. Hybrid Inheritance 5. Hierarchical Inheritance
  • 22. SINGLE INHERITANCE When a child class inherits from only one parent class, it is called as single inheritance.
  • 23. MULTIPLE INHERITANCE  When a child class inherits from multiple parent classes.  Python supports multiple inheritance. We specify all parent classes as comma separated list in bracket.
  • 24. MULTILEVEL INHERITANCE Multi-level inheritance is achieved when a derived class inherits another derived class.
  • 25. HYBRID INHERITANCE  This form combines more than one form of inheritance. Basically, it is a blend of more than one type of inheritance
  • 26. POLYMORPHISM  Polymorphism is ability to use a common interface for multiple forms (data types).  It refers to the use of a single type entity (method, operator or object) to represent different types in different scenarios.
  • 27. POLYMORPHISM CONTD. We can implement polymorphism by  Overloading operator method constructor  Overriding method constructor
  • 28. POLYMORPHISM CONTD.  Method Overloading, a way to create multiple methods with the same name but different arguments.  It is achieved by passing different number of arguments or by passing different types of arguments.
  • 29. POLYMORPHISM CONTD.  Method Overriding: It allows us to change the implementation of function in the child class which is defined in the parent class.  Following conditions must be met for overriding a function: Inheritance should be implemented. Method overriding cannot be done within a class. We need to derive a child class from a parent class. The function that is redefined in the child class should have the same definition/ signature as in the parent class i.e. same number of parameters.
  • 30. DATA ABSTRACTION  It is the process of hiding the real implementation of an application from the user and emphasizing only on usage of it.  E.g. when you use mobile, we need not know how pressing a key changes the volume level. We just need to know that pressing up button increases the volume and the down button reduces the volume. Why Do We Need Abstraction? Through the process of abstraction, a programmer can hide all the irrelevant data/process of an application in order to reduce complexity, provide security and increase the efficiency.
  • 31. DATA ABSTRACTION CONTD. Abstract class  Abstract class are the classes which contain one or more abstract method. Abstract Method  Abstract Methods are the methods which only have declaration and no definition.

Notes de l'éditeur

  1. For eg: Let's assume, we need to replicate a Zoo in a program. We will list out all the animals and create functions for them or we can make a single function and handle all animals in that function. Now, animals have distinct behaviors along with some common behaviors and all of them have some pattern. All animals eat, sleep, walk, make noise and run but their patterns are different. Also, animals have distinct properties like Elephants have trunk, Rhinos have horns etc. To address this, we need to pass each and every property as a parameter to the function so that function knows what to do for which animal combination. Even if we created separate functions for each animal to reduce the complexity, it would still be difficult to complete the process without any glitches(unexpected fault). So, there is need for an approach which is more realistic.
  2. As we came across the drawbacks of procedure oriented programming, let's learn how oop fixed them and gave us a much simpler and at the same time a robust way to programming which is still in use.