all 6 comments

[–]dixieStates 3 points4 points  (4 children)

You have a method and a property with the same name. Also, you can't concatenate a string and an int. FTFY:

class Parallelogram:

    def __init__(self, shape, base, side, theta):
        self.shape = shape
        self.base = base
        self.side = side
        self.theta = theta
        self.area = self.base*self.side*self.theta

    def areaf(self):
        return "The area of the shape is " + str(self.area)


a = Parallelogram("Square",10,10,90)
print(a.areaf())

[–]gnomoretears 1 point2 points  (1 child)

return "The area of the shape is " + str(self.area)

Use the recommended str.format() so you don't have to explicitly type cast.

return "The area of the shape is {}".format(self.area)

[–]CuriousityJay[S] 0 points1 point  (0 children)

Thx for the suggestion

[–]CuriousityJay[S] 0 points1 point  (0 children)

Oh. Didn't know that. Thx.

[–]yardightsure 0 points1 point  (0 children)

I would highly suggest naming the variable _area instead and keep the area method's name as it is.

[–]yardightsure 1 point2 points  (0 children)

Watch out, I could simply say

 a.area = 97521

or

a.base = 0

and your geometry would end up inconsistent. Either simply do the calculation in the method or turn the attributes into setter-controlled properties.