• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Classes and objects
 

 

Statistics

Views

Total Views
295
Views on SlideShare
295
Embed Views
0

Actions

Likes
0
Downloads
9
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Classes and objects Classes and objects Presentation Transcript

    • 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
    • CLASSES AND OBJECTS
    • CLASS• A Class is a way to bind the data and itsassociated functions together.• An object is an instance of a class.• Ideas about classes are:– A class can have subclasses that can inherit all orsome of the characteristics of the class.– Subclasses can also define their own methods andvariables that are not part of their superclass.
    •  ACCESS SPECIFIER• private -members of a class are accessibleonly from within other members of the sameclass• protected -members are accessible frommembers of their same class and frommembers of their derived classes.• public members are accessible from anywherewhere the object is visible
    • Access Specifier in python• There are only public or private attributes• Private-Anything that starts with twounderscores is private to the class (or module).• Everything else is publicEg:-class Simple(object):def __init__():self.__x = 0
    • Declaring a class in pythonclass name:statements
    • OBJECT• An object that contains information about auser-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, andbehaviors.– State-properties– Behavior-a set of methods.
    • Built-In Class Attributes:__dict__ : Dictionary containing the classs namespace.__doc__ : Class documentation string, or None ifundefined.__name__: Class name.__module__: Module name in which the class isdefined. This attribute is "__main__" in interactivemode.__bases__ : A possibly empty tuple containing thebase classes, in the order of their occurrence in thebase class list.
    • Examplesclass class1 :name = “Classes in Python”difficulty= “easy”>> print class1.nameClasses in Python>> print class1.difficultyeasy
    • >> 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
    • >> you = tutorials()>> me = tutorials()>> you.printname(“aneesh”)OutputClasses in Python
    • Output
    • If this presentation helped you, please visit ourpage facebook.com/baabtra and like it.Thanks in advance.www.baabtra.com | www.massbaab.com |www.baabte.com
    • Contact Us