Jan-20-2019, 03:59 PM
"Figure5" is a class, not an instance of a class. As such, there is no "self" to provide to circumference(). If you remove the property annotation from circumference, a second error appears because of the lack of self. You need to instantiate the class and then call circumference to make it work.
On a side note, you may encounter issues with Figure5 because of multiple inheritance because both of its parents have a circumference method.
On a side note, you may encounter issues with Figure5 because of multiple inheritance because both of its parents have a circumference method.
class Figure1: def __init__(self, x, y, z): self._x = x self._y = y self._z = z def area(self): return (self._x + self._y) * self._z / 2 class Figure2(Figure1): def __init__(self, x, z): super().__init__(x=x, y=x, z=z) class Figure3(Figure2): def circumference(self): return self._x * 4 class Figure4(Figure2): def __init__(self, x, y): super().__init__(x=x,z=y) def circumference(self): return 2 * self._x + 2 * self._z class Figure5(Figure4, Figure3): def __init__(self, x): super().__init__(x=x, y=x) a = Figure5(9) print(a.area()) print(a.circumference()) if __name__ == "__main__": a.x = 9 assert a.circumference() == 36 assert a.area() == 81