Advertisement
endzie_fyrge

[27] Triangle

Aug 8th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import math
  2.  
  3. print("Enter 3 side lengths.")
  4. x = float(input("Side one: "))
  5. y = float(input("Side two: "))
  6. z = float(input("Side three: "))
  7.  
  8. if x + y > z and x + z > y and y + z > x:
  9.     half_perimeter = (x + y + z) / 2
  10.     area = math.sqrt(half_perimeter * (half_perimeter - x) * (half_perimeter - z) * (half_perimeter - y))
  11.     print(f"The three sides can make a triangle, and it's area is {area}.")
  12. else:
  13.     print("It's not possible to make a triangle out of the given sides.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement