# Python Program to check Triangle is Valid or Not

Write a Python Program to Check Triangle is Valid or Not using user specified angles. Remember, any triangle is valid, if sum of 3 angles in a triangle is equal to 180

## Python Program to check Triangle is Valid or Not Example 1

This python program helps user to enter all angles of a triangle. Next, we used If Else statement to check whether the sum of given angles is equal to 180 or not. If True, print statement prints a valid triangle. Otherwise, python program prints as invalid triangle.

```# Python Program to check Triangle is Valid or Not

a = int(input('Please Enter the First Angle of a Triangle: '))
b = int(input('Please Enter the Second Angle of a Triangle: '))
c = int(input('Please Enter the Third Angle of a Triangle: '))

# checking Triangle is Valid or Not
total = a + b + c

if total == 180:
print("\nThis is a Valid Triangle")
else:
print("\nThis is an Invalid Triangle")```

## Python Program to verify Triangle is Valid or Not Example 2

In the above Python example, we forgot to check whether any of the angle is zero or not. So, we used Logical AND operator to make sure all angles are greater than 0

```a = int(input('Please Enter the First Angle of a Triangle: '))
b = int(input('Please Enter the Second Angle of a Triangle: '))
c = int(input('Please Enter the Third Angle of a Triangle: '))

# checking Triangle is Valid or Not
total = a + b + c

if (total == 180 and a != 0 and b != 0 and c != 0):
print("\nThis is a Valid Triangle")
else:
print("\nThis is an Invalid Triangle")```
``````Please Enter the First Angle of a Triangle: 70
Please Enter the Second Angle of a Triangle: 70
Please Enter the Third Angle of a Triangle: 40

This is a Valid Triangle
>>>
=================== RESTART: /Users/suresh/Desktop/simple.py ===================
Please Enter the First Angle of a Triangle: 90
Please Enter the Second Angle of a Triangle: 90
Please Enter the Third Angle of a Triangle: 0

This is an Invalid Triangle
>>>``````