• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
127
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd
  • 2. CLASSES AND OBJECTS
  • 3. 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.
  • 4.  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
  • 5. 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 publicEg:-class Simple(object): def __init__(): self.__x = 0
  • 6. Declaring a class in pythonclass name: statements
  • 7. 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.
  • 8. Built-In Class Attributes:__dict__ : Dictionary containing the classs 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.
  • 9. Examplesclass class1 : name = “Classes in Python” difficulty= “easy”>> print class1.nameClasses in Python>> print class1.difficultyeasy
  • 10. >> object1 = class1()>> print object1.nameClasses in python•Defining Methods/functions in classesclass tutorials : name = “Classes in Python” difficulty= “easy” def printname(self,name) : print self.name
  • 11. >> you = tutorials()>> me = tutorials()>> you.printname(“aneesh”)OutputClasses in Python
  • 12. Output
  • 13. 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
  • 14. Contact Us