Robots

Report a typo

In the template below you can see a hierarchy of robots. There is a base class Robot and a subclass ServiceRobot. Objects of the class Robot have two attributes: name and variety. variety represents the function of the robot, for example, service or military. The get_info method returns information about a particular instance.

The ServiceRobot represents the "service" variety of robots. Objects of this class have only the name attribute.

Your task is to change the __init__ method of the class ServiceRobot so that get_info() returns the correct information for the objects of ServiceRobot. There are several ways to do it, but we ask you to use the super() function.

Write a program in Python 3
class Robot:
def __init__(self, name, variety):
self.name = name
self.variety = variety
print("Robot")

def get_info(self):
return "{} is a {} robot".format(self.name, self.variety)


class ServiceRobot(Robot):
def __init__(self, name):
self.name = name


chappi = ServiceRobot("Chappi")
print(chappi.get_info())
___

Create a free account to access the full topic