Can these numbers form a triangle? or not?

Write a python function to check whether three given numbers can form the sides of a triangle. 

Hint: Three numbers can be the sides of a triangle if none of the numbers are greater than or equal to the sum of the other two numbers.

SOLUTION:

def form_triangle(num1,num2,num3):
success="Triangle can be formed"
failure="Triangle can't be formed"
if(((num1+num2)>num3)and((num2+num3)>num1) and ((num3+num1)>num2)): # check the condition if true then the sides are not the part of the triangle.
print(success)
return success
else: print(failure)
return failure
form_triangle(1, 7, 3)
form_triangle(10, 7, 3)

Post a Comment

0 Comments