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:
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:
a,b and c are the lengths of the sides, and s= (a+b+c)/ 2
Here is the Solution for the problem above:
s = semi_prmtr(a,b,c)
area = math.sqrt(s*(s-a)*(s-b)*(s-c))