SlideShare une entreprise Scribd logo
1  sur  13
Inheritanceand
Composition.
Built-In Functions for
Classes.
Presented by
S. Sameena Fathima
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.
WhatAreInheritanceand Composition?
• Inheritance and composition are two major concepts in object
oriented programming that model the relationship between two
classes.
• Inheritance models what is called an is a relationship. This
means that when you have a Derived class that inherits from
a Base class, you created a relationship where Derived is
a specialized version of Base.
• Composition is a concept that models a has a relationship. It
enables creating complex types by combining objects of other
types. This means that a class Composite can contain an object
of another class Component.
Inheritence
 In the figure, classes are represented as boxes. The
inheritance relationship is represented by an arrow
pointing from Derived Class(Child Class) to Base
Class(Parent Class). The extends keyword denotes
that the Child Class is inherited or derived
from Parent Class.
 Inheritance is used where a class wants to derive the
nature of parent class and then modify or extend the
functionality of it.
Syntax
# Parent class class Parent :
# Constructor
# Variables of Parent class
# Methods ... ...
# Child class inheriting Parent class
class Child(Parent) :
# constructor of child class
# variables of child class
# methods of child class ... ...
Composition
Syntax
class A :
# variables of class A
# methods of class A ... ...
class B :
# by using "obj" we can access member's of class A. obj =
A()
# variables of class B
# methods of class B
Built in fuctions
Function Description
abs() Returns the absolute value of a number
all() Returns True if all items in an iterable
object are true
any() Returns True if any item in an iterable
object is true
ascii() Returns a readable version of an object.
Replaces none-ascii characters with
escape character
bin() Returns the binary version of a number
bool() Returns the boolean value of the
specified object
bytearray() Returns an array of bytes
bytes() Returns a bytes object
callable() Returns True if the specified object is
callable, otherwise False
chr() Returns a character from the specified
Unicode code.
classmethod() Converts a method into a class method
compile() Returns the specified source as an
object, ready to be executed
complex() Returns a complex number
delattr() Deletes the specified attribute (property
or method) from the specified object
dict() Returns a dictionary (Array)
dir() Returns a list of the specified object's
properties and methods
divmod() Returns the quotient and the
remainder when argument1 is divided
by argument2
enumerate() Takes a collection (e.g. a tuple) and
returns it as an enumerate object
eval() Evaluates and executes an expression
exec() Executes the specified code (or
object)
filter() Use a filter function to exclude items in
an iterable object
float() Returns a floating point number
format() Formats a specified value
frozenset() Returns a frozenset object
getattr() Returns the value of the specified
attribute (property or method)
globals() Returns the current global symbol
table as a dictionary
hasattr() Returns True if the specified object
has the specified attribute
(property/method)
hash() Returns the hash value of a specified
object
help() Executes the built-in help system
hex() Converts a number into a hexadecimal
value
id() Returns the id of an object
input() Allowing user input
int() Returns an integer number
isinstance() Returns True if a specified object is an
instance of a specified object
issubclass() Returns True if a specified class is a
subclass of a specified object
iter() Returns an iterator object
And there are various other built in functions.
Thank You!

Contenu connexe

Similaire à python p.pptx

Inheritance And Traits
Inheritance And TraitsInheritance And Traits
Inheritance And TraitsPiyush Mishra
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented ProgrammingGamindu Udayanga
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdfprasnt1
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceEng Teong Cheah
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4Richard Jones
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 

Similaire à python p.pptx (20)

About Python
About PythonAbout Python
About Python
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Inheritance And Traits
Inheritance And TraitsInheritance And Traits
Inheritance And Traits
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
 
Module IV_updated(old).pdf
Module IV_updated(old).pdfModule IV_updated(old).pdf
Module IV_updated(old).pdf
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
Oop java
Oop javaOop java
Oop java
 
Python-Classes.pptx
Python-Classes.pptxPython-Classes.pptx
Python-Classes.pptx
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
scala.ppt
scala.pptscala.ppt
scala.ppt
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 
chap11.ppt
chap11.pptchap11.ppt
chap11.ppt
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 

Plus de Sameenafathima4 (15)

ai.pptx
ai.pptxai.pptx
ai.pptx
 
dip.pptx
dip.pptxdip.pptx
dip.pptx
 
iot.pptx
iot.pptxiot.pptx
iot.pptx
 
women empowerment.pptx
women empowerment.pptxwomen empowerment.pptx
women empowerment.pptx
 
CLOUD COMPUTING.pptx
CLOUD COMPUTING.pptxCLOUD COMPUTING.pptx
CLOUD COMPUTING.pptx
 
crypto.pptx
crypto.pptxcrypto.pptx
crypto.pptx
 
crypto.pptx
crypto.pptxcrypto.pptx
crypto.pptx
 
nosql.pptx
nosql.pptxnosql.pptx
nosql.pptx
 
Features of Android OS.pptx
Features of Android OS.pptxFeatures of Android OS.pptx
Features of Android OS.pptx
 
Creating windows
Creating windowsCreating windows
Creating windows
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Swing components
Swing components Swing components
Swing components
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
 
JAVA SERVER PAGE
JAVA SERVER PAGEJAVA SERVER PAGE
JAVA SERVER PAGE
 

Dernier

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Dernier (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

python p.pptx

  • 1. Inheritanceand Composition. Built-In Functions for Classes. Presented by S. Sameena Fathima 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. WhatAreInheritanceand Composition? • Inheritance and composition are two major concepts in object oriented programming that model the relationship between two classes. • Inheritance models what is called an is a relationship. This means that when you have a Derived class that inherits from a Base class, you created a relationship where Derived is a specialized version of Base. • Composition is a concept that models a has a relationship. It enables creating complex types by combining objects of other types. This means that a class Composite can contain an object of another class Component.
  • 5.  In the figure, classes are represented as boxes. The inheritance relationship is represented by an arrow pointing from Derived Class(Child Class) to Base Class(Parent Class). The extends keyword denotes that the Child Class is inherited or derived from Parent Class.  Inheritance is used where a class wants to derive the nature of parent class and then modify or extend the functionality of it.
  • 6. Syntax # Parent class class Parent : # Constructor # Variables of Parent class # Methods ... ... # Child class inheriting Parent class class Child(Parent) : # constructor of child class # variables of child class # methods of child class ... ...
  • 8. Syntax class A : # variables of class A # methods of class A ... ... class B : # by using "obj" we can access member's of class A. obj = A() # variables of class B # methods of class B
  • 9. Built in fuctions Function Description abs() Returns the absolute value of a number all() Returns True if all items in an iterable object are true any() Returns True if any item in an iterable object is true ascii() Returns a readable version of an object. Replaces none-ascii characters with escape character bin() Returns the binary version of a number bool() Returns the boolean value of the specified object
  • 10. bytearray() Returns an array of bytes bytes() Returns a bytes object callable() Returns True if the specified object is callable, otherwise False chr() Returns a character from the specified Unicode code. classmethod() Converts a method into a class method compile() Returns the specified source as an object, ready to be executed complex() Returns a complex number delattr() Deletes the specified attribute (property or method) from the specified object dict() Returns a dictionary (Array) dir() Returns a list of the specified object's properties and methods
  • 11. divmod() Returns the quotient and the remainder when argument1 is divided by argument2 enumerate() Takes a collection (e.g. a tuple) and returns it as an enumerate object eval() Evaluates and executes an expression exec() Executes the specified code (or object) filter() Use a filter function to exclude items in an iterable object float() Returns a floating point number format() Formats a specified value frozenset() Returns a frozenset object getattr() Returns the value of the specified attribute (property or method) globals() Returns the current global symbol table as a dictionary hasattr() Returns True if the specified object has the specified attribute (property/method)
  • 12. hash() Returns the hash value of a specified object help() Executes the built-in help system hex() Converts a number into a hexadecimal value id() Returns the id of an object input() Allowing user input int() Returns an integer number isinstance() Returns True if a specified object is an instance of a specified object issubclass() Returns True if a specified class is a subclass of a specified object iter() Returns an iterator object And there are various other built in functions.