Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def get_area(self):
  2.         """
  3.        Calculates shape's area.
  4.  
  5.        Returns:
  6.            float: area of the shape
  7.        """
  8.  
  9.         if self.shape == "Circle":
  10.             self.area = math.pi * self.r ** 2
  11.         elif self.shape == "Triangle" or self.shape == "Equilateral Triangle":
  12.             self.area = math.sqrt(self.s*(self.s-self.a)*(self.s-self.b)*(self.s-self.c))
  13.         elif self.shape == "Rectangle" or self.shape == "Square":
  14.             self.area = self.a * self.b
  15.         elif self.shape == "Regular Pentagon":
  16.             self.area = self.a**2 * math.sqrt(5*(5+2*math.sqrt(5)))/4
  17.  
  18.         return self.area
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement