SlideShare a Scribd company logo
1 of 14
Object oriented programming
• 5 things in oops concept
1. Polymorphism
2. Encapsulation
3. Inheritance
4. Abstraction
5. Classes & Objects
Class
• Python is an Object Oriented Programming
language.
• Almost everything in Python is an Object , with its
properties and methods.
• Class is a set of variables and functions.
• class keyword is used to create Class.
Some Points to create python class
• Classes are created by keyword class.
• Attributes are the variables that belong to a class.
• Attributes are always public and can be accessed
using dot(.) operator.
• Eg: Myclass.MyAttribute
Create a class
• To create a class , use the keyword class:
Syntax : class definition
class ClassName:
#statement
Example,
class MyClass:
x=5
print(MyClass)
Create an Object
• An Object is an instance of a Class.
Syntax : Object definition
Obj=ClassName()
Print(obj.atrr)
• Example,
class MyClass:
x=5
p1 = MyClass()
print(p1.x)
Output:
5
The __init__() Function
• All classes have a function called __init__(),which is
always executed when the class is being initiated.
• Use the __init__() function to assign values to object
properties.
• Example,
class Person:
def __init__(self , name , age):
self.name=name
self.age=age
p1 = person(“Lizi”,21)
print(p1.name)
print(p1.age)
Output:
Lizi
21
The __str__() Function
• The __str__() function controls what should be
returned when the class object is represented
as a string
Example,
class Person:
def __init__(self , name , age):
self.name=name
self.age=age
p1 = person(“Lizi”,21)
Output:
<__main__.Person object at 0x15039e602100>
The self parameter
• The self parameter is a reference to the current
instance of the class , and is used to access
variables that belongs to the class.
Real time example
Ootty class
Person 1 Person 2
Object
Education Party
• Example,
class ooty:
def education(self):
print(“research for flowers”)
def boathouse(self):
print(“Let’s Party”)
Person 1=ooty()
Person 2=ooty()
Person 1.education()
Person 2.boathouse()
• Output:
research for flowers
Let’s Party

More Related Content

Similar to PYTHON - OBJECT ORIENTED PROGRAMMING .pptx

Computer Science ACW Intro to OOP L7.pptx
Computer Science ACW Intro to OOP L7.pptxComputer Science ACW Intro to OOP L7.pptx
Computer Science ACW Intro to OOP L7.pptxEdmondLabule2
 
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Abdullah Jan
 
Bccon use notes objects in memory and other useful
Bccon   use notes objects in memory and other usefulBccon   use notes objects in memory and other useful
Bccon use notes objects in memory and other usefulFrank van der Linden
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programmingSaket Khopkar
 
Python Classes and Objects part13
Python Classes and Objects  part13Python Classes and Objects  part13
Python Classes and Objects part13Vishal Dutt
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingMH Abid
 
COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxFarooqTariq8
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programmingSrinivas Narasegouda
 
Week10 packages using objects in objects
Week10 packages using objects in objectsWeek10 packages using objects in objects
Week10 packages using objects in objectskjkleindorfer
 
Definning class.pptx unit 3
Definning class.pptx unit 3Definning class.pptx unit 3
Definning class.pptx unit 3thenmozhip8
 
Python Programming - VI. Classes and Objects
Python Programming - VI. Classes and ObjectsPython Programming - VI. Classes and Objects
Python Programming - VI. Classes and ObjectsRanel Padon
 

Similar to PYTHON - OBJECT ORIENTED PROGRAMMING .pptx (20)

Python-Classes.pptx
Python-Classes.pptxPython-Classes.pptx
Python-Classes.pptx
 
Computer Science ACW Intro to OOP L7.pptx
Computer Science ACW Intro to OOP L7.pptxComputer Science ACW Intro to OOP L7.pptx
Computer Science ACW Intro to OOP L7.pptx
 
oop 3.pptx
oop 3.pptxoop 3.pptx
oop 3.pptx
 
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++
 
Bccon use notes objects in memory and other useful
Bccon   use notes objects in memory and other usefulBccon   use notes objects in memory and other useful
Bccon use notes objects in memory and other useful
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programming
 
Python Classes and Objects part13
Python Classes and Objects  part13Python Classes and Objects  part13
Python Classes and Objects part13
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
bhaskars.pptx
bhaskars.pptxbhaskars.pptx
bhaskars.pptx
 
COMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptxCOMP111-OOP-Introduction_138257.pptx
COMP111-OOP-Introduction_138257.pptx
 
Python_Unit_2 OOPS.pptx
Python_Unit_2  OOPS.pptxPython_Unit_2  OOPS.pptx
Python_Unit_2 OOPS.pptx
 
Java
JavaJava
Java
 
Object oriented approach in python programming
Object oriented approach in python programmingObject oriented approach in python programming
Object oriented approach in python programming
 
Week10 packages using objects in objects
Week10 packages using objects in objectsWeek10 packages using objects in objects
Week10 packages using objects in objects
 
Python ppt
Python pptPython ppt
Python ppt
 
Definning class.pptx unit 3
Definning class.pptx unit 3Definning class.pptx unit 3
Definning class.pptx unit 3
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
Python Programming - VI. Classes and Objects
Python Programming - VI. Classes and ObjectsPython Programming - VI. Classes and Objects
Python Programming - VI. Classes and Objects
 
python note.pdf
python note.pdfpython note.pdf
python note.pdf
 

More from SubashiniRathinavel (11)

Basic Introduction to Python Programming
Basic Introduction to Python ProgrammingBasic Introduction to Python Programming
Basic Introduction to Python Programming
 
VB.NET Datatypes.pptx
VB.NET Datatypes.pptxVB.NET Datatypes.pptx
VB.NET Datatypes.pptx
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Quiz
QuizQuiz
Quiz
 
DSS
DSSDSS
DSS
 
Wireless lan security(10.8)
Wireless lan security(10.8)Wireless lan security(10.8)
Wireless lan security(10.8)
 
Wireless LAN
Wireless LANWireless LAN
Wireless LAN
 
SHA
SHASHA
SHA
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Online
OnlineOnline
Online
 
Cryptography
CryptographyCryptography
Cryptography
 

Recently uploaded

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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
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
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
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
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
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
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 

Recently uploaded (20)

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
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).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
 
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...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
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
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

PYTHON - OBJECT ORIENTED PROGRAMMING .pptx

  • 1. Object oriented programming • 5 things in oops concept 1. Polymorphism 2. Encapsulation 3. Inheritance 4. Abstraction 5. Classes & Objects
  • 2. Class • Python is an Object Oriented Programming language. • Almost everything in Python is an Object , with its properties and methods. • Class is a set of variables and functions. • class keyword is used to create Class.
  • 3. Some Points to create python class • Classes are created by keyword class. • Attributes are the variables that belong to a class. • Attributes are always public and can be accessed using dot(.) operator. • Eg: Myclass.MyAttribute
  • 4. Create a class • To create a class , use the keyword class: Syntax : class definition class ClassName: #statement Example, class MyClass: x=5 print(MyClass)
  • 5. Create an Object • An Object is an instance of a Class. Syntax : Object definition Obj=ClassName() Print(obj.atrr)
  • 6. • Example, class MyClass: x=5 p1 = MyClass() print(p1.x) Output: 5
  • 7. The __init__() Function • All classes have a function called __init__(),which is always executed when the class is being initiated. • Use the __init__() function to assign values to object properties.
  • 8. • Example, class Person: def __init__(self , name , age): self.name=name self.age=age p1 = person(“Lizi”,21) print(p1.name) print(p1.age) Output: Lizi 21
  • 9. The __str__() Function • The __str__() function controls what should be returned when the class object is represented as a string
  • 10. Example, class Person: def __init__(self , name , age): self.name=name self.age=age p1 = person(“Lizi”,21) Output: <__main__.Person object at 0x15039e602100>
  • 11. The self parameter • The self parameter is a reference to the current instance of the class , and is used to access variables that belongs to the class.
  • 12. Real time example Ootty class Person 1 Person 2 Object Education Party
  • 13. • Example, class ooty: def education(self): print(“research for flowers”) def boathouse(self): print(“Let’s Party”) Person 1=ooty() Person 2=ooty() Person 1.education() Person 2.boathouse()
  • 14. • Output: research for flowers Let’s Party