Python program that test if integer values can form a triangle
###### Posted by Samath
Last Updated: November 06, 2014

If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if one of the sticks is 12 inches long and the other two are 1 inch long, it is clear that you will not be able to get the shorter sticks to meet. For any three lengths, there is a simple test to see if it is possible to form a triangle:
“If any of the three lengths is greater than the sum of the other two, then you cannot form a
triangle. Otherwise, you can.”

a) Write a function in Python named is_triangle that takes three integers as arguments, and prints either True or False depending on whether you can or cannot form a triangle from sticks with the given lengths.

b) Write a function in Python called semi_prmtr that takes three integers a, b and c as arguments and returns the result of the following calculation:
(a+b+c)/ 2

c) Modify the is_triangle (call it is_triangleV2) function so that it now returns a boolean value. Using is_triangleV2, and semi_prmtr, write a function called tri_Area that takes three integers as arguments and returns the area of a valid triangle.
Use the following formula:
area= vs(s-a)(s-b)(s-c)
where:
a,b and c are the lengths of the sides, and s= (a+b+c)/ 2

Here is the Solution for the problem above:

`import math`

a).

```def is_triangle(x,y,z):
if(z>(x+y)):
print ("False")
elif(y>(x+z)):
print ("False")
elif(x>(z+y)):
print ("False")
else:
print ("True")```

b).

```def semi_prmtr(a,b,c):
return (a+b+c)/2```

c).

```def is_triangleV2(x,y,z):
if(z>(x+y)):
return False
elif(y>(x+z)):
return False
elif(x>(z+y)):
return False
else:
return True

def tri_Area(a,b,c):
if(is_triangleV2(a,b,c)):
s = semi_prmtr(a,b,c)
area = math.sqrt(s*(s-a)*(s-b)*(s-c))
return area
else:
print("Invalid Triangle")
```
###### C Program to Calculate Area of Scalene Triangle
Samath | Jan 01, 2017
###### C Program to Calculate Area of Equilatral Triangle
Samath | Jan 01, 2017
###### C Program to Calculate Area of Right angle Triangle
Samath | Jan 01, 2017
###### Upside Down Triangle using C++
Samath | Jan 05, 2017
###### Polygon, Rectangle and Triangle Class in Python
Samath | Jan 20, 2024
###### Java program that reads an integer and prints how many digits the number has
Samath | Feb 11, 2021
###### C++ Summing the digits in an integer
Samath | Jan 06, 2021
###### Recursive function that find the sum of digits in a integer using C++
Samath | Dec 24, 2014
###### Summing the Digits in an Integer using Python
Samath | Mar 02, 2015
###### C program that receives an integer number and determines if it is a prime number
Samath | Jun 01, 2015
###### Convert Integer to Roman Numeral using C#
Samath | Jan 20, 2024
###### C program that takes a non- negative integer number as input and prints its binary representation
Samath | Jan 01, 2017
###### C++ Convert an Integer to Roman Numeral
Samath | Jan 20, 2024
###### Java program that reads an integer and prints if it's positive or negative
Samath | Feb 11, 2021