Python Classes and objects

Unit 10 > Computer Science > Class 12 > Samacheer Kalvi - English Medium

Objectives


• Understand the fundamental concepts of Object Oriented Programming like: Classes, Objects, Constructor and Destructor. • Gain the knowledge of creating classes and objects in Python. • Create classes with Constructors. • Write complex programs in Python using classes.

Summary


• Python is an Object Oriented Programming language. • Classes and Objects are the key features of Object Oriented Programming. • In Python, a class is defined by using the keyword class. • Variables defined inside a class is called as “Class Variable” and function are called as “Methods”. • The process of creating object is called as “Class Instantiation”. • Constructor is the special function that is automatically executed when an object of a class is created. • In Python, there is a special function called “init” is used as Constructor. • Destructor is also a special method gets execution automatically when an object exits from the scope. • In Python, __del__( ) method is used as destructor. • A variable prefixed with double underscore is becomes private in nature.