Program to check if a triangle of positive area is possible with the given angles using Python

Introduction

The task is to find whether a triangle of positive area can be constructed from the given angles.

Program

def check(angle1, angle2, angle3):
#None of the angles should be zero and sum of all three angles must be 180 degree
    if(angle1 != 0 and angle2 != 0 and angle3 != 0 and (angle1 + angle2 + angle3)== 180):
#Sum of any two angle must be greater or equal to the third one
        if((angle1 + angle2) >= angle3 or (angle2 + angle3) >= angle1 or (angle1 + angle3) >= angle2):
            print("Can be constructed")
        else:
            print("Cannot be constructed")
    else:
        print("Cannot be constructed")


check(60, 60, 60)

Output

Program to check if a triangle of positive area is possible with the given angles using Python

Explanation

To construct the triangle of positive area, the triangle should satisfy the following conditions:

  • None of the angle should be zero.
  • The sum of all the three angles must be 1800.
  • The sum of any two angles must be greater than or equal to the third angle.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.