Define an instance variable in other methods

Define an instance variable in other methods:

Explanation of the Below Code:

- We define an instance variable in other methods.

- We create a class with the init method.

- We create a myself-named class.

- Then we define the init method with the self and name parameters, then create an instance variable.

- Then we define the setAge method with the self and age parameters, then create an instance variable.

- Then we define the getAge method with the self-parameter, then we take the instance variable of the getAge method right to the return statement which retrieves the instance variable value.

- Then we create an 
a-named instance(object) with one argument of myself class.

- Then we call the setAge method with the one argument using the a-named instance(object).

- Then we call the getAge method using the a-named instance(object)
 in the print function.

Comments