Hello,
In this exercise we are asked to add 2 new classes that inherit from another class. Both DriveBot and WalkBot inherit from Robot.
We are asked to use superclass constructor and in each of the new classes we need to pass 1 new parameter : In the class DriveBot, motor_speed
and in WalkBot , ‘steps_per_minute’ as the parameter for speed
in the super class.
In the explanation for the answer provided 'motor_speed´ and ‘steps-per_motor’ are put in place of ‘speed´’. Here answered provided:
**class DriveBot(Robot):**
** def __init__(self, motor_speed = 0, direction = 180, sensor_range = 10):**
** super().__init__(motor_speed, direction, sensor_range)**
** **
**class WalkBot(Robot):**
** def __init__(self, steps_per_minute = 0, direction = 180, sensor_range = 10, step_length = 5):**
** super().__init__(steps_per_minute, direction, sensor_range)**
** self.step_length = step_length*
I need help confirming how does the interpreter knows that these new parameters will occupy the value of ‘speed’ in Robot as ‘init’ in this class as there is no relation declared that associates new parameter name to the old parameter name.
I am assuming that it is because of the position. that Robot will assume any value that comes in that place holder position as ‘speed’. But I would like reassurance or to be corrected in case I am mistaken.
Here ‘init’ from Robot:
**def __init__(self, speed = 0, direction = 180, sensor_range = 10):**
** self.speed = speed**
** self.direction = direction**
** self.sensor_range = sensor_range**
** self.obstacle_found = False**
** Robot.robot_count += 1**
** self.id = Robot.robot_count**
Here link to the excercise:
https://www.codecademy.com/courses/learn-python-3/articles/advanced-python-code-challenges-classes
For reference:
I am currently around 23% progress for the Data Analyst Path and about 93% progress for the Learn Python 3 Course.
I am located in the Dom. Rep.