vencinachev

Triangle - Python

Mar 22nd, 2021 (edited)
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import math
  2. a = float(input('Enter a: '))
  3. b = float(input('Enter b: '))
  4. c = float(input('Enter c: '))
  5.  
  6. if a <= 0 or b <= 0 or c <= 0 or a + b <= c or a + c <= b or b + c <= a:
  7.     print('Invalid triangle')
  8. else:
  9.     P = a + b + c
  10.     p = P / 2
  11.     S = math.sqrt(p*(p-a)*(p-b)*(p-c))
  12.     print('P = ' + str(P))
  13.     print('S = ' + str(S))
Add Comment
Please, Sign In to add comment