{"id":22959,"date":"2021-09-29T20:13:34","date_gmt":"2021-09-29T14:43:34","guid":{"rendered":"https:\/\/python-programs.com\/?p=22959"},"modified":"2021-11-22T18:35:36","modified_gmt":"2021-11-22T13:05:36","slug":"python-program-to-check-whether-triangle-is-valid-or-not-if-sides-are-given","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-whether-triangle-is-valid-or-not-if-sides-are-given\/","title":{"rendered":"Python Program to Check Whether Triangle is Valid or Not if Sides are Given"},"content":{"rendered":"

In the previous article, we have discussed Python Program for Triangular Matchstick Number<\/a>
\nGiven three sides of a triangle, the task is to check if the given triangle is valid or not for the given 3 sides in python.<\/p>\n

A triangle is said to be valid if the sum of its two sides is greater than the third side.<\/p>\n

Conditions to check if the given triangle is valid or Not:<\/strong><\/p>\n

Let a, b, c\u00a0 are the 3 sides of a triangle. It must satisfy the following conditions:<\/p>\n

a + b > c<\/p>\n

a + c > b<\/p>\n

b + c > a<\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given First side = 5\r\nGiven Second side = 7\r\nGiven Third side = 6<\/pre>\n

Output:<\/strong><\/p>\n

Yes, the triangle is valid for the given three sides<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given First side = 4\r\nGiven Second side = 9\r\nGiven Third side = 2<\/pre>\n

Output:<\/strong><\/p>\n

The triangle is invalid for the given three sides<\/pre>\n

Program to Check Whether Triangle is Valid or Not if Sides are Given in Python<\/h2>\n

Below are the ways to check if the given triangle is valid or not for the given 3 sides in python:<\/p>\n