Hey Guys,
I have a question as mentioned in the title. can you use one method's result for another method in the same Class?. I wish to use the result of the area method in the get_amount_inside method. Is there a way to do this? or put the equation for area L*W.
Thanks for your Help!
I have a question as mentioned in the title. can you use one method's result for another method in the same Class?. I wish to use the result of the area method in the get_amount_inside method. Is there a way to do this? or put the equation for area L*W.
Thanks for your Help!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class Rectangle: def __init__( self , width, height): self .width = width self .height = height def get_area( self ): area = self .width * self .height return area def get_amount_inside( self , shape): self .shape = shape if self .shape = = "sq" : num_times = self .area / ( self .width * self .width) return num_times |