Advertisement
fevzi02

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

Oct 25th, 2021
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. class Triangle:
  2.     def __init__(self, a=0, b=0, c=0):
  3.         self.a = a
  4.         self.b = b
  5.         self.c = c
  6.     def specify_length(self):
  7.         self.a = int(input("сторона a = "))
  8.         self.b = int(input("сторона b = "))
  9.         self.c = int(input("сторона c = "))
  10.     def examination(self):
  11.         bool = False
  12.         if self.a + self.b > self.c and self.a + self.c > self.b and self.b + self.c > self.a:
  13.             bool = True
  14.         return bool
  15.     def area_calculation(self):
  16.         if self.examination():
  17.             p = self.perimeter()/2
  18.             return (p * (p - self.a) * (p - self.b) * (p - self.c)) ** 0.5
  19.         else:
  20.             return "Такого треугольника не существует!"
  21.     def perimeter(self):
  22.         if self.examination():
  23.             return self.a + self.b + self.c
  24.         else:
  25.             return False
  26.  
  27. t1 = Triangle(100,200,150)
  28. t1.specify_length()
  29. print(t1.examination())
  30. print(t1.area_calculation())
  31. print(t1.perimeter())
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement