SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
CLASSES AND OBJECTS
CLASS
• A Class is a way to bind the data and its
  associated functions together.
• An object is an instance of a class.
• Ideas about classes are:
  – A class can have subclasses that can inherit all or
    some of the characteristics of the class.
  – Subclasses can also define their own methods and
    variables that are not part of their superclass.
 ACCESS SPECIFIER
• private -members of a class are accessible
  only from within other members of the same
  class
• protected -members are accessible from
  members of their same class and from
  members of their derived classes.
• public members are accessible from anywhere
  where the object is visible
Access Specifier in python
• There are only public or private attributes
• Private-Anything that starts with two
   underscores is private to the class (or module).
• Everything else is public
Eg:-
class Simple(object):
   def __init__():
      self.__x = 0
Declaring a class in python
class name:
    statements
OBJECT
• An object that contains information about a
  user-defined type
• An object represents an entity in the real world
• Distinctly identified
  • For example, a student, a desk, a circle
• An object has an unique identity, state, and
  behaviors.
  – State-properties
  – Behavior-a set of methods.
Built-In Class Attributes:
__dict__ : Dictionary containing the class's namespace.
__doc__ : Class documentation string, or None if
  undefined.
__name__: Class name.
__module__: Module name in which the class is
  defined. This attribute is "__main__" in interactive
  mode.
__bases__ : A possibly empty tuple containing the
  base classes, in the order of their occurrence in the
  base class list.
Examples
class class1 :
   name = “Classes in Python”
   difficulty= “easy”

>> print class1.name
Classes in Python
>> print class1.difficulty
easy
>> object1 = class1()
>> print object1.name
Classes in python
•Defining Methods/functions in classes
class tutorials :
      name = “Classes in Python”
      difficulty= “easy”
      def printname(self,name) :
         print self.name
>> you = tutorials()
>> me = tutorials()
>> you.printname(“aneesh”)

Output
Classes in Python
Output
If this presentation helped you, please visit our
           page facebook.com/baabtra and like it.
                 Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us

Weitere ähnliche Inhalte

Was ist angesagt?

Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVATech_MX
 
Python Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaPython Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaEdureka!
 
Java Inheritance | Java Course
Java Inheritance | Java Course Java Inheritance | Java Course
Java Inheritance | Java Course RAKESH P
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPTPooja Jaiswal
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in JavaKurapati Vishwak
 
Inner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in javaInner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in javaAdil Mehmoood
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in JavaRavi_Kant_Sahu
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in javaRicha Singh
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member FunctionsMuhammad Hammad Waseem
 
Java Inheritance
Java InheritanceJava Inheritance
Java InheritanceVINOTH R
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsHarsh Patel
 
Java Inner Class
Java Inner ClassJava Inner Class
Java Inner ClassDeeptiJava
 
Introducing classes
Introducing classesIntroducing classes
Introducing classesRiaz Ahmed
 

Was ist angesagt? (20)

Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVA
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Python Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaPython Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | Edureka
 
Java Inheritance | Java Course
Java Inheritance | Java Course Java Inheritance | Java Course
Java Inheritance | Java Course
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
Inner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in javaInner classes ,annoumous and outer classes in java
Inner classes ,annoumous and outer classes in java
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Python - object oriented
Python - object orientedPython - object oriented
Python - object oriented
 
javainheritance
javainheritancejavainheritance
javainheritance
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Inner class
Inner classInner class
Inner class
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Java Inner Class
Java Inner ClassJava Inner Class
Java Inner Class
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
 

Andere mochten auch (9)

Exception Handling
Exception HandlingException Handling
Exception Handling
 
Cms
CmsCms
Cms
 
It careers
It careersIt careers
It careers
 
Project management difference between industry and college
Project management difference between industry and collegeProject management difference between industry and college
Project management difference between industry and college
 
Complex number
Complex numberComplex number
Complex number
 
Fb career profile
Fb career profileFb career profile
Fb career profile
 
Exception handling
Exception handlingException handling
Exception handling
 
Xml
XmlXml
Xml
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 

Ähnlich wie Disclaimer and Introduction to Classes and Objects in Python

Ähnlich wie Disclaimer and Introduction to Classes and Objects in Python (20)

Object oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptxObject oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptx
 
class and object in c++.pptx
class and object in c++.pptxclass and object in c++.pptx
class and object in c++.pptx
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
A1771937735_21789_14_2018__16_ Nested Classes.ppt
A1771937735_21789_14_2018__16_ Nested Classes.pptA1771937735_21789_14_2018__16_ Nested Classes.ppt
A1771937735_21789_14_2018__16_ Nested Classes.ppt
 
27c
27c27c
27c
 
27csharp
27csharp27csharp
27csharp
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
DAY_1.4.pptx
DAY_1.4.pptxDAY_1.4.pptx
DAY_1.4.pptx
 
Lecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptxLecture-10_PHP-OOP.pptx
Lecture-10_PHP-OOP.pptx
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
Object Oriented Programming.pptx
Object Oriented Programming.pptxObject Oriented Programming.pptx
Object Oriented Programming.pptx
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in java
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
UNIT - IIInew.pptx
UNIT - IIInew.pptxUNIT - IIInew.pptx
UNIT - IIInew.pptx
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Class and objects
Class and objectsClass and objects
Class and objects
 
Oops
OopsOops
Oops
 

Mehr von baabtra.com - No. 1 supplier of quality freshers

Mehr von baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
 

Disclaimer and Introduction to Classes and Objects in Python

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 4. CLASS • A Class is a way to bind the data and its associated functions together. • An object is an instance of a class. • Ideas about classes are: – A class can have subclasses that can inherit all or some of the characteristics of the class. – Subclasses can also define their own methods and variables that are not part of their superclass.
  • 5.  ACCESS SPECIFIER • private -members of a class are accessible only from within other members of the same class • protected -members are accessible from members of their same class and from members of their derived classes. • public members are accessible from anywhere where the object is visible
  • 6. Access Specifier in python • There are only public or private attributes • Private-Anything that starts with two underscores is private to the class (or module). • Everything else is public Eg:- class Simple(object): def __init__(): self.__x = 0
  • 7. Declaring a class in python class name: statements
  • 8. OBJECT • An object that contains information about a user-defined type • An object represents an entity in the real world • Distinctly identified • For example, a student, a desk, a circle • An object has an unique identity, state, and behaviors. – State-properties – Behavior-a set of methods.
  • 9. Built-In Class Attributes: __dict__ : Dictionary containing the class's namespace. __doc__ : Class documentation string, or None if undefined. __name__: Class name. __module__: Module name in which the class is defined. This attribute is "__main__" in interactive mode. __bases__ : A possibly empty tuple containing the base classes, in the order of their occurrence in the base class list.
  • 10. Examples class class1 : name = “Classes in Python” difficulty= “easy” >> print class1.name Classes in Python >> print class1.difficulty easy
  • 11. >> object1 = class1() >> print object1.name Classes in python •Defining Methods/functions in classes class tutorials : name = “Classes in Python” difficulty= “easy” def printname(self,name) : print self.name
  • 12. >> you = tutorials() >> me = tutorials() >> you.printname(“aneesh”) Output Classes in Python
  • 13.
  • 15.
  • 16. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com