fevzi02

ПЗ - 1. Задание 6.

Oct 25th, 2021
640
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Trapezoid:
  2.     def __init__(self, a, b, c, d):
  3.         self.b_base = self.finding_parties(a, d)
  4.         self.t_base = self.finding_parties(b, c)
  5.         self.l_side = self.finding_parties(a, b)
  6.         self.r_side = self.finding_parties(c, d)
  7.  
  8.     def finding_parties(self, coord1, coord2):
  9.         return ( (coord2[0]-coord1[0]) ** 2 + (coord2[1]-coord1[1]) ** 2 ) ** 0.5
  10.  
  11.     def examination(self):
  12.         if self.l_side == self.r_side:
  13.             return True
  14.         else:
  15.             return False
  16.  
  17.     def perimeter(self):
  18.         return self.t_base + self.b_base + self.l_side + self.r_side
  19.     def square(self):
  20.         p = self.perimeter()/2
  21.         if self.examination():
  22.             return ((p-self.t_base) * (p-self.b_base) * (p-self.l_side) * (p-self.r_side)) ** 0.5
  23.         else:
  24.             return "Трапеция не равнобокая."
  25.     def print_side(self):
  26.         return (self.t_base, self.b_base, self.l_side, self.r_side)
  27.  
  28. t1 = Trapezoid((-6,0), (-2,3), (2,3), (6,0))
  29. print(t1.examination())
  30. print(t1.perimeter())
  31. print(t1.square())
  32. print(t1.print_side())
  33.  
RAW Paste Data