Sitemap

Oops In Python

2 min readAug 16, 2022
Press enter or click to view image in full size

Class is a blueprint, plan, design, or model which contains full information about something.

Three Important things In Oops:

Class:

  • Class is a Blueprint or a model which contains full information about something.
  • what is the need for classes? : To create an object we need a class

Object:

  • The physical existence of a class is nothing but an object. (because if you don't want an object there is no need to create a class)
  • In programming, we can add functionality by using objects.

Reference Variable:

  • Reference variables are to reference objects, by using reference variables we can invoke the functionality of the object.
  • For a single object, there can be changes in multiple references.

To create a class :

class < Name_of_the_class >:

# In oops name of the class always starts with a capital letter.

* """ Document_string""" # It is to give an idea about a particular class and it's functionality.

Get Rajat Singh’s stories in your inbox

Join Medium for free to get updates from this writer.

* Properties (we can define by using variables)
* Actions (we can add some functionality! What an object can perform by using methods)

  • Every class has properties and behavior
  1. Properties (data) are specified by variable.
  2. Behavior is specified by methods
  • Types of variables in Object-oriented-programing.
  1. Instance variable (Object level variable)
  2. Static variable ( Class level variable)
  3. local variable (Method level variable)
  • Three types of methods in python Class.
  1. Instance method
  2. Class methods
  3. Static method

Self Keyword:

  1. The first parameter of a method or a class is generally referred to as a self.
  2. Self refers to the calling object. That is Jessa above.
  3. This argument is implicitly passed by the python interpreter and need not be mentioned while calling.

Class variable:

Class variables are something that is defined inside a class. Not in method Not even in the default method which is __init__.

Instance variable:

Instance variables are something that is defined inside a Constructor method(Function).

--

--