SlideShare a Scribd company logo
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!

More Related Content

PPTX
Java Unit 2(Part 1)
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
DOCX
C questions
PPTX
PPTX
C++ Presen. tation.pptx
PPT
Object Oriented Programming In .Net
PDF
OOP, Networking, Linux/Unix
PDF
Lecture20 vector
Java Unit 2(Part 1)
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
C questions
C++ Presen. tation.pptx
Object Oriented Programming In .Net
OOP, Networking, Linux/Unix
Lecture20 vector

Similar to python p.pptx (20)

DOCX
Fundamental classes in java
DOCX
New microsoft office word document (2)
PPTX
About Python
PPTX
Unit ii
PDF
Inheritance And Traits
PPTX
python1 object oriented programming.pptx
PPTX
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
PPTX
classes-objects in oops java-201023154255.pptx
PPT
Unit 3 Java
PPTX
cbse class 12 Python Functions2 for class 12 .pptx
PPTX
Unit3 part1-class
PPTX
C++ Object Oriented Programming
PDF
Module IV_updated(old).pdf
PPT
Classes, objects and methods
PPT
Introductory Example: A Trip to the Aviary.ppt
PPTX
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PPTX
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
PPT
Oop java
PPTX
Python-Classes.pptx
PPT
Class 7 - PHP Object Oriented Programming
Fundamental classes in java
New microsoft office word document (2)
About Python
Unit ii
Inheritance And Traits
python1 object oriented programming.pptx
c91632a4-2e92-4edf-b750-358da15ed1b1.pptx
classes-objects in oops java-201023154255.pptx
Unit 3 Java
cbse class 12 Python Functions2 for class 12 .pptx
Unit3 part1-class
C++ Object Oriented Programming
Module IV_updated(old).pdf
Classes, objects and methods
Introductory Example: A Trip to the Aviary.ppt
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PYTHON-COURSE-PROGRAMMING-UNIT-IV--.pptx
Oop java
Python-Classes.pptx
Class 7 - PHP Object Oriented Programming
Ad

More from Sameenafathima4 (15)

PPTX
PPTX
dip.pptx
PPTX
iot.pptx
PPTX
women empowerment.pptx
PPTX
CLOUD COMPUTING.pptx
PPTX
crypto.pptx
PPTX
crypto.pptx
PPTX
nosql.pptx
PPTX
Features of Android OS.pptx
PPTX
Creating windows
PPTX
Code optimization
PPTX
Swing components
PPTX
dsa.pptx
PPTX
anatomy of a jsp page & jsp syntax.pptx
PPTX
JAVA SERVER PAGE
dip.pptx
iot.pptx
women empowerment.pptx
CLOUD COMPUTING.pptx
crypto.pptx
crypto.pptx
nosql.pptx
Features of Android OS.pptx
Creating windows
Code optimization
Swing components
dsa.pptx
anatomy of a jsp page & jsp syntax.pptx
JAVA SERVER PAGE
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Lesson notes of climatology university.
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PDF
Classroom Observation Tools for Teachers
PPTX
Presentation on HIE in infants and its manifestations
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Cell Types and Its function , kingdom of life
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
2.FourierTransform-ShortQuestionswithAnswers.pdf
Lesson notes of climatology university.
human mycosis Human fungal infections are called human mycosis..pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
RMMM.pdf make it easy to upload and study
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
Classroom Observation Tools for Teachers
Presentation on HIE in infants and its manifestations
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Final Presentation General Medicine 03-08-2024.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3

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.