- Get link
- Other Apps
- Get link
- Other Apps
Declare a Constructor
Explanation of the Below Code:
- We create a class with the init method.
- We create a chirag-named class.
- Then we define the init method with self-parameters, then create an instance variable.
- Then we define a readName-named method with a self-parameter, we take the instance variable in the print function which returns the instance variable value.
- Then we create an n-named instance(object) of the chirag class.
- Then we call the readName method using the n-named instance(object).
- Syntax: def __init__(self):
- We create a chirag-named class.
- Then we define the init method with self-parameters, then create an instance variable.
- Then we define a readName-named method with a self-parameter, we take the instance variable in the print function which returns the instance variable value.
- Then we create an n-named instance(object) of the chirag class.
- Then we call the readName method using the n-named instance(object).
- Syntax: def __init__(self):
- Get link
- Other Apps
Comments
Post a Comment