Question 3
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
class Shape:
def __init__(self, colour):
self.colour = colour
class Circle(Shape):
def __init__(self, radius):
super().__init__()
self.radius = radius
c = Circle(5)
- A TypeError: Shape.__init__ needs colour, but super().__init__() passes nothing Correct
- B It creates the circle with colour None
- C AttributeError
- D RecursionError
Correct Answer: Option A
super().__init__ follows the parent's signature: pass colour along, e.g. def __init__(self, radius, colour="red").
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!