Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Trapezoid:
- def __init__(self, a, b, c, d):
- self.b_base = self.finding_parties(a, d)
- self.t_base = self.finding_parties(b, c)
- self.l_side = self.finding_parties(a, b)
- self.r_side = self.finding_parties(c, d)
- def finding_parties(self, coord1, coord2):
- return ( (coord2[0]-coord1[0]) ** 2 + (coord2[1]-coord1[1]) ** 2 ) ** 0.5
- def examination(self):
- if self.l_side == self.r_side:
- return True
- else:
- return False
- def perimeter(self):
- return self.t_base + self.b_base + self.l_side + self.r_side
- def square(self):
- p = self.perimeter()/2
- if self.examination():
- return ((p-self.t_base) * (p-self.b_base) * (p-self.l_side) * (p-self.r_side)) ** 0.5
- else:
- return "Трапеция не равнобокая."
- def print_side(self):
- return (self.t_base, self.b_base, self.l_side, self.r_side)
- t1 = Trapezoid((-6,0), (-2,3), (2,3), (6,0))
- print(t1.examination())
- print(t1.perimeter())
- print(t1.square())
- print(t1.print_side())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement