Ch-31 Types Of Variable And Methods In Python Oops | Python tutorial for beginners in hindi

preview_player
Показать описание
Enroll To Premium Python With Data Structure Solve Upto 300+ Ds Questions
+91 9472395194

As we know, Class is a prototype or a design of any object in the existence. It represents a set of properties and behaviour of an object.

Object is a physical existence of the class, it can be referred as an instance of a class.
A class contains:
1. Variables ( which depicts certain properties of an object ) and
2. Methods ( represents a set of behaviour of an object ).

Variables in a class are related to an object, to a class or to a method.

There are three different types of variables in OOPs in python.

Instance variable ( Object level variable )
Static variable ( Class level variable )
Local variable ( Method level variable )
Three different types of Methods in OOPs in python.

Instance method
Static method
Class method
Reference variable: This variable is a reference or a pointer to an object to perform operations on that object . Reference variables always points to a object.

What is self keyword in python oops ?
self keyword is an implicit reference variable to the current object of the class and is available only inside the class, not outside of the class, so that variable and methods inside the class can use other variables/methods inside the same class.

Accessor and Mutator methods in python
So, you all must be acquainted with the fact that the internal data of an object must be kept private. But there should be some methods in the class interface that can permit the user of an object to access and alter the data (that is stored internally) in a calm manner. Therefore, for that case we have two methods namely Accessors and Mutators that are helpful in accessing and altering respectively, internally stored data.

Accessor Method (getter method): This method is used to access the state of the object i.e, the data hidden in the object can be accessed from this method. However, this method cannot change the state of the object, it can only access the data hidden. We can name these methods with the word get.

Mutator Method (setter method) : This method is used to mutate/modify the state of an object i.e, it alters the hidden value of the data variable. It can set the value of a variable instantly to a new value. This method is also called as update method. Moreover, we can name these methods with the word set.

Notest Download Link
Рекомендации по теме
Комментарии
Автор

awesome institute in the world loves u wap institute and sr saurav

technicalmateen
join shbcf.ru