Class in Python

https://www.youtube.com/watch?v=53dkdz4jndg

1Class

* Class is collection of attribut and method

* All class of python derived from Object class by default

* Class name must be start with Capital latter

2How to create class?

class Classname(object): def __init__(self): self.variable_name=value def method_name(self): //body of metho

3__init__()
This methos is used to initialize the varibles.This is a special method. We do not call this method explicitly. It will automatically call as a construtor.

4Self
Self is a variable which refers to current class instance/object
5Rules of class

* This class name can be any valid identifier * It can't be Python reserve word. * A valid class name starts with a letter, followed by any number of letter, number or underscores * A Class name generaly start with capital letter.

6Object

* Object is class type variable or class instance. To use a class, we should create an object to class

Syntax:- object_name =class_name() object_name =class_name(arg)

call variable and method of object of class object_name.variable_name object_name.method_name()

7Oops oncept or object orianted

: Class : Object : Abstraction : Encapsulation : Inheritance : Polymorphism

X