class
Upload: baabtracom-mentoring-partner-first-programming-school-in-india
Post on 29-Nov-2014
403 views
DESCRIPTION
OOPsTRANSCRIPT
![Page 1: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/1.jpg)
![Page 2: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/2.jpg)
Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
![Page 3: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/3.jpg)
CLASSES AND OBJECTS
![Page 4: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/4.jpg)
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.
![Page 5: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/5.jpg)
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
![Page 6: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/6.jpg)
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
![Page 7: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/7.jpg)
Declaring a class in pythonclass name: statements
![Page 8: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/8.jpg)
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.
![Page 9: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/9.jpg)
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.
![Page 10: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/10.jpg)
Examplesclass class1 :
name = “Classes in Python”difficulty= “easy”
>> print class1.nameClasses in Python>> print class1.difficultyeasy
![Page 11: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/11.jpg)
>> object1 = class1()>> print object1.nameClasses in python
•Defining Methods/functions in classes
class tutorials :
name = “Classes in Python”
difficulty= “easy”
def printname(self,name) :
print self.name
![Page 12: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/12.jpg)
>> you = tutorials()>> me = tutorials()>> you.printname(“aneesh”)
Output
Classes in Python
![Page 13: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/13.jpg)
![Page 14: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/14.jpg)
Output
![Page 15: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/15.jpg)
![Page 16: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/16.jpg)
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
![Page 17: Class](https://reader033.vdocuments.mx/reader033/viewer/2022061201/54793d1fb4af9f836a8b4617/html5/thumbnails/17.jpg)
Contact Us