Feedback, second project done! Python's Polygon Area Calculator

Would appreciate some feedback on my project! Get_shape_inside was quite tricky but I got it in the end.


Hi @Renato

There isn’t a link or any code in your post.


Hello @craig.lunney , I fixed it. See if it works now. Thanks for the heads-up!

Hi @Renato

I can see your code now, it looks absolutely spot on easy to follow and passes all the tests.

1 Like

Hi @craig.lunney sorry to object, but it does not really. The get_shape_inside method returns correct results only with certain parameters( including those in the project description), but not all! for eg. when tested with the following:
rect = Rectangle(25, 8)
sq = Square(2)
small_rect = Rectangle(10,5)

it returns 48 and 2, instead of 50 and 4 respectively.
@Renato here are some suggestions if you don’t mind:

  1. The “else” part of your “get picture method”(6 lines of code) could also be done in a single line:
    return ("*".rjust(self.w,"*")+"\n")*self.h
  2. The amount_inside is literally the area of the instance object // that of the passed object.
    def get_amount_inside(self,shape):
    area_int = shape.w * shape.h
    area_ext = self.w * self.h
    return area_ext//area_int

that’s 18 blocks of code replaced with 4 and returns correct value each time!

@ac.azubyke I appreciate you reviewing the code and all feedback is good feedback, however if you read through the post you will see that the code belongs to the original poster @Renato it is not my own.