python

Can we create any number of reference variables for an object?

Yes, An object in the memory can be pointed by any number of reference variables as shown in the below example. In the above example, you can see we are creating the reference variable “s_1” that contains the address(memory location) of an object of the “Student” class. We are now assigning a value of s_1 …

Can we create any number of reference variables for an object? Read More »

Calling one method within another method within a class in python

Here in the above example, you can see “add()” is getting called within “add_another_method()” by using a variable self followed by. (dot) followed by method name (self.add()) . To call other methods within another method within a class, you have to use the “self” variable along with the method which you want to call. Contributed …

Calling one method within another method within a class in python Read More »

Accessing class properties and behaviour outside the class.

After creating an object, you can access the class properties and behavior by using object name followed by dot operator (.) followed by properties name/ instance variable/behavior/method name. Syntax: object_name.properties or object_name.behavior In the above example, we have created one object of class Car called car_object and for accessing properties we are using car_object.price (properties/ …

Accessing class properties and behaviour outside the class. Read More »