SlideShare a Scribd company logo
1 of 14
Inheritance and Composition.
Built-In Functions for
Classes.
Presented by
M.Vidhya
I-M.Sc (CS)
Nadar Saraswathi College of Arts and
Science
WHAT IS PYTHON?
• Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics.
• Its high-level built in data structures, combined with dynamic typing and dynamic binding,
make it very attractive for Rapid Application Development, as well as for use as a scripting
or glue language to connect existing components together.
• Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost
of program maintenance.
• Python supports modules and packages, which encourages program modularity and code
reuse.
COMPOSITION:
we will refine the class person , that comprised the instance attribute name , DOB
and address in addition to the class attribute person count. while creating objects such as ‘24-
10-1990’ as value of the date of birth(DOB). We also defined MyDate class comprising three
components day, month and year . To use this representation of the date in the class Person , we
only need to import the Mydate class in the script and there is no change in the description of
class person.
The use of MyDate class to create instance of person class:
>>dob=MyDate(24,10,1900)
>>p1=person(‘Rajat,Mittal’,dob,’B-23,Malviya nagar , delhi’)
>>print(p1)
Name: Rajat Mittal
DOB :24-10-1990
Address:b-23,Malviya Nagar, Delhi
That data attribute dob of object p1 is type MyDate .here we have used an object
of another class Mydate as an attribute of the class person. The process of using
objects of the classes as attribute values is called object composition. It is
important to observe that we have already using this concept subconsciously.
While creating object of class person earlier , we used object of system –define
class str as value of attributes name, DOB, and address . We could have, equally
well, used the object MyDate (24,10,1990) directly as an argument , while invoking
the constructor, instead of first creating it as dob ,as shown below
>>p1=person(‘Rajat Mittal’, MyDate(24,10,1990),b-23,Malviya Nagar ,Delhi’)
INHERITANCE:
Inheritance is an important feature of object oriented programming that
imparts ability to a class to inherit properties and behavior of another class. The
class object includes a rich set of special type of function.
Person
is a
Employee
Parent and child class
SINGLE INHERITANCE:
when inheritance involves a derived class that derives
its properties from a single base class is called single inheritance. As
another example think of a manager I a factory . The manager would have
all the attribute of an employee and may have some new attributes like
managerial pay.
Person
is an
Manager
Employee and manager class
HIERARCHICAL INHERITANCE:
A derived class is like any other class and may serve as
base class for another class derived from it and so on. Each derived
class may define its new attributes. Thus inheritance allows us to
create a class hierarchy also called type hierarchy.
Vehicle
is an is an
passenger Commercial
vehicle vehicle
is a is a is a
car Auto Bus
MULTIPLE INHERITANCE:
In the case of multiple inheritance , a subclass derives its attributes from two or
more classes . We make use of multiple inheritance to schedule appointments by
creating a class Appointment .since an appointment will comprise date and time ,
we may inherit the classes MyDate and MyTime in the class appoinment.
MyDate MyTime
Appoinment
Classes Clerk and Manager
We have already developed the class MyDate. We give details of the class
MyTime having data attributes hours, minutes and seconds .
ABSTRACT METHODS:
An abstract method in a base class identifies the functionality
that should be implemented by all its subclasses .However,since
the implementation of an abstract method would differ from one
subclass to another , often the method body comprises just a pass
statement .Every subclass of the base class will override this
method with its implementation. A
Class containning abstract methods is called abstract class.
BUILT IN FUNCTIONS:
And there are various other built in functions
THANK
YOU

More Related Content

Similar to python.pptx

Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)
dannygriff1
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
koolkampus
 
Application package
Application packageApplication package
Application package
JAYAARC
 

Similar to python.pptx (20)

Oops
OopsOops
Oops
 
Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)
 
BIS08 Application Development - II
BIS08 Application Development - IIBIS08 Application Development - II
BIS08 Application Development - II
 
Lecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With PythonLecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With Python
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
 
Structures
StructuresStructures
Structures
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
creating objects and Class methods
creating objects and Class methodscreating objects and Class methods
creating objects and Class methods
 
Class methods
Class methodsClass methods
Class methods
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Application package
Application packageApplication package
Application package
 

More from Mvidhya9 (9)

womenempowerment.ppt
womenempowerment.pptwomenempowerment.ppt
womenempowerment.ppt
 
IOT.ppt
IOT.pptIOT.ppt
IOT.ppt
 
Color image processing ppt
Color image processing pptColor image processing ppt
Color image processing ppt
 
artifical intelligence ppt.
artifical intelligence ppt.artifical intelligence ppt.
artifical intelligence ppt.
 
cloud computing ppt
cloud computing pptcloud computing ppt
cloud computing ppt
 
cryptography.pptx
cryptography.pptxcryptography.pptx
cryptography.pptx
 
nosql.PPT.pptx
nosql.PPT.pptxnosql.PPT.pptx
nosql.PPT.pptx
 
DOS.pptx
DOS.pptxDOS.pptx
DOS.pptx
 
Peephole optimization
Peephole optimization Peephole optimization
Peephole optimization
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 

python.pptx

  • 1. Inheritance and Composition. Built-In Functions for Classes. Presented by M.Vidhya I-M.Sc (CS) Nadar Saraswathi College of Arts and Science
  • 2. WHAT IS PYTHON? • Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. • Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. • Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. • Python supports modules and packages, which encourages program modularity and code reuse.
  • 3. COMPOSITION: we will refine the class person , that comprised the instance attribute name , DOB and address in addition to the class attribute person count. while creating objects such as ‘24- 10-1990’ as value of the date of birth(DOB). We also defined MyDate class comprising three components day, month and year . To use this representation of the date in the class Person , we only need to import the Mydate class in the script and there is no change in the description of class person. The use of MyDate class to create instance of person class: >>dob=MyDate(24,10,1900) >>p1=person(‘Rajat,Mittal’,dob,’B-23,Malviya nagar , delhi’) >>print(p1) Name: Rajat Mittal DOB :24-10-1990 Address:b-23,Malviya Nagar, Delhi
  • 4. That data attribute dob of object p1 is type MyDate .here we have used an object of another class Mydate as an attribute of the class person. The process of using objects of the classes as attribute values is called object composition. It is important to observe that we have already using this concept subconsciously. While creating object of class person earlier , we used object of system –define class str as value of attributes name, DOB, and address . We could have, equally well, used the object MyDate (24,10,1990) directly as an argument , while invoking the constructor, instead of first creating it as dob ,as shown below >>p1=person(‘Rajat Mittal’, MyDate(24,10,1990),b-23,Malviya Nagar ,Delhi’)
  • 5. INHERITANCE: Inheritance is an important feature of object oriented programming that imparts ability to a class to inherit properties and behavior of another class. The class object includes a rich set of special type of function. Person is a Employee Parent and child class
  • 6. SINGLE INHERITANCE: when inheritance involves a derived class that derives its properties from a single base class is called single inheritance. As another example think of a manager I a factory . The manager would have all the attribute of an employee and may have some new attributes like managerial pay. Person is an Manager Employee and manager class
  • 7. HIERARCHICAL INHERITANCE: A derived class is like any other class and may serve as base class for another class derived from it and so on. Each derived class may define its new attributes. Thus inheritance allows us to create a class hierarchy also called type hierarchy. Vehicle is an is an passenger Commercial vehicle vehicle is a is a is a car Auto Bus
  • 8. MULTIPLE INHERITANCE: In the case of multiple inheritance , a subclass derives its attributes from two or more classes . We make use of multiple inheritance to schedule appointments by creating a class Appointment .since an appointment will comprise date and time , we may inherit the classes MyDate and MyTime in the class appoinment. MyDate MyTime Appoinment Classes Clerk and Manager We have already developed the class MyDate. We give details of the class MyTime having data attributes hours, minutes and seconds .
  • 9. ABSTRACT METHODS: An abstract method in a base class identifies the functionality that should be implemented by all its subclasses .However,since the implementation of an abstract method would differ from one subclass to another , often the method body comprises just a pass statement .Every subclass of the base class will override this method with its implementation. A Class containning abstract methods is called abstract class.
  • 11.
  • 12.
  • 13. And there are various other built in functions