;

Python Program to Check Whether a Triangle is Valid or Not


Tutorialsrack 12/05/2020 Python

In this python program, we will learn how to check whether a triangle is valid or not. A triangle is valid if the total sum of all the sides is equal to 1800 otherwise it is not a valid triangle.

Here is the source code of the program to check whether a triangle is valid or not.

Python Program to Check Whether a Triangle is Valid or Not
# Python Program to Check Whether a Triangle is Valid or Not

# Take the Input from the User
a = int(input("Enter the First Angle of a Triangle: "))
b = int(input("Enter the Second Angle of a Triangle: "))
c = int(input("Enter the Third Angle of a Triangle: "))

# Sum of all the Sides
total = a + b + c

# checking Triangle is Valid or Not
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")
Output

Enter the First Angle of a Triangle: 50

Enter the Second Angle of a Triangle: 20

Enter the Third Angle of a Triangle: 110

 

This is a Valid Triangle



Enter the First Angle of a Triangle: 56

Enter the Second Angle of a Triangle: 12

Enter the Third Angle of a Triangle: 31

 

This is an Invalid Triangle


Related Posts



Comments

Recent Posts
Tags