-1
class Trapezoid:

    def __init__(self, h, a, b):
        self.h = h
        self.a = a
        self.b = b

    def getArea(self):
        return 0.5 (a + b) * h

small_trapezoid = Trapezoid(6, 3, 4)
print('The area of the trapezoid is', small_trapezoid.getArea())
Jay Will
  • 1
  • 1

2 Answers2

1

That's right, it's not defined. You meant self.a, as well as the other two.

return 0.5 (self.a + self.b) * self.h

Though then you have another error: TypeError: 'float' object is not callable

wjandrea
  • 28,235
  • 9
  • 60
  • 81
0

So you are trying to access 'a', 'b' and 'h' values in the getArea method, you might want to change it to

    def getArea(self):
        return 0.5 (self.a + self.b) * self.h
Kingsley Solomon
  • 481
  • 1
  • 4
  • 9