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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
0 Comments