Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_area(self):
- """
- Calculates shape's area.
- Returns:
- float: area of the shape
- """
- if self.shape == "Circle":
- self.area = math.pi * self.r ** 2
- elif self.shape == "Triangle" or self.shape == "Equilateral Triangle":
- self.area = math.sqrt(self.s*(self.s-self.a)*(self.s-self.b)*(self.s-self.c))
- elif self.shape == "Rectangle" or self.shape == "Square":
- self.area = self.a * self.b
- elif self.shape == "Regular Pentagon":
- self.area = self.a**2 * math.sqrt(5*(5+2*math.sqrt(5)))/4
- return self.area
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement