CODING PRACTICE - 3 Valid Triangle - 2
Valid Triangle - 2
Given the lengths of three sides of a triangle, write a program to check whether the triangle is valid or not.
For a triangle to be valid, the sum of lengths of any two sides of the triangle must be greater than the third side.
Input
The first line of input will contain the first side of the triangle.
The second line of input will contain the second side of the triangle.
The third line of input will contain the third side of the triangle.
Output
If the sum of the lengths of any two sides of the triangle is greater than the third side, print "It's a Triangle". In all other cases, print "It's not a Triangle".
Explanation
For example, if the first side is 4, the second side is 5, and the third side is 3, then the sum of any two sides is greater than the third side:
4 + 5 > 3
5 + 3 > 4
3 + 4 > 5
So the output should be "It's a Triangle".
For a triangle to be valid, the sum of lengths of any two sides of the triangle must be greater than the third side.
Input
The first line of input will contain the first side of the triangle.
The second line of input will contain the second side of the triangle.
The third line of input will contain the third side of the triangle.
Output
If the sum of the lengths of any two sides of the triangle is greater than the third side, print "It's a Triangle". In all other cases, print "It's not a Triangle".
Explanation
For example, if the first side is 4, the second side is 5, and the third side is 3, then the sum of any two sides is greater than the third side:
4 + 5 > 3
5 + 3 > 4
3 + 4 > 5
So the output should be "It's a Triangle".
Sample Input 1Sample Output 1
4 5 3
It's a Triangle
Sample Input 2Sample Output 2
6 3 2
It's not a Triangle\
code:
a=int(input())
b=int(input())
c=int(input())
x=(a+b)>c
y=(b+c)>a
z=(c+a)>b
if x and y and z :
print("It's a Triangle")
else:
print("It's not a Triangle")
Comments
Post a Comment