Class with Class Variable and Instance Variable

Class with Class Variable and Instance Variable:

Explanation of the Below Code:

- We access the class variable and instance variable using class and instance(object).

- We create a class with the init method.

- We create a myself-named class.

- We create a name-named class variable.

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

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

- Then we access the class variable using the a and b-named instance(object) in the print function.

- Then we access the instance variable using the and b-named instance(object) in the print function.

- Then we access the class variable using the myself class in the print function.

Comments