1) Write a function is_rightangled which, given the length of three sides of a triangle, will determine whether the triangle is right-angled. Assume that the third argument to the function is always the longest side. It will return True if the triangle is right-angled, or False otherwise.

2) Extend the above program so that the sides can be given to the function in any order.

The 1st question is really easy and i could finish it but i can't do the 2nd question. Although there is answer to this, i still don't understand.

- Code: Select all
`def is_rightangled(a,b,c):`

is_rightangled = False

largest = a

if b > largest:

# largest = b

if abs((a**2) + (c**2) - (b**2)) < 0.001:

is_rightangled = True

if c > largest:

# largest = c

if abs((a**2) + (b**2) - (c**2)) < 0.001:

is_rightangled = True

else:

# largest = a

if abs((c**2) + (b**2) - (a**2)) < 0.001:

is_rightangled = True

return is_rightangled

I wonder if there is any other simpler solution to this question and i hope for full explanation about the above answer. Thank you !