Answer the question
In order to leave comments, you need to log in
How to solve the problem of determining the three sides of a triangle?
Task:
Determine the type of triangle (acute-angled, obtuse-angled, right-angled) with the given sides.
You must output one of the words: "right" for a right triangle, "acute" for an acute triangle, "obtuse" for an obtuse triangle, or "impossible" if the input numbers do not form a triangle.
What's wrong with my way?
a = int(input())
b = int(input())
c = int(input())
if pow(c, 2) == pow(a, 2) + pow(b, 2):
print(' right')
elif pow(b, 1) + pow(c, 2) - pow(a, 2) > 0:
print('acute')
elif pow(a, 2) + pow(b, 2) < pow( c, 2):
print('obtuse')
elif (a + b) <= c or (a + b) <= b or (c + b) <= a:
Answer the question
In order to leave comments, you need to log in
I would use the law of cosinesThick, xoo )
a, b, c = 3, 4, 5
a, b, c = sorted([a, b, c])
if a + b <= c:
print('impossible')
else:
t = a * a + b * b - c * c
print(('right', 'obtuse', 'acute')[(t < 0) - (t > 0)])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question