0

I'm doing python developing.

class Figure():

    def __init__(self, a, b, c):
        self.dots = a
        self.height = b
        self.width = c

    def calcArea(self):
        area = self.height * self.width
        print(area)

    def Tellarea(self):
        x= calcArea(self)
        print(self.figure+" area :", x)

In this case, the x part is said to be wrong. What should I do to write the function values directly from another function?

I'm a beginner coder. Sorry for the cute question.

MisterMiyagi
  • 44,374
  • 10
  • 104
  • 119

1 Answers1

0

You need to return the value using the return statement as:

def calcArea(self):
    area = self.height * self.width
    print(area)
    return area

By default, a None value is returned if nothing is returned explicitly.

Also, you need to call class methods with self and not pass self as argument:

x = self.calcArea()
Krishna Chaurasia
  • 8,924
  • 6
  • 22
  • 35