- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Check if a triangle of positive area is possible with the given angles in Python

Suppose we have three angles. We have to check whether it is possible to create a triangle of positive area with these angles or not.

So, if the input is like a = 40 b = 120 c = 20, then the output will be True as the sum of 40 + 120 + 20 = 180.

To solve this, we will follow these steps −

- if a, b and c are not 0 and (a + b + c) is same as 180, then
- if (a + b) >= c or (b + c) >= a or (a + c) >= b, then
- return True

- otherwise,
- return False

- if (a + b) >= c or (b + c) >= a or (a + c) >= b, then
- otherwise,
- return False

Let us see the following implementation to get better understanding −

## Example

def solve(a, b, c): if a != 0 and b != 0 and c != 0 and (a + b + c) == 180: if (a + b)>= c or (b + c)>= a or (a + c)>= b: return True else: return False else: return False a = 40 b = 120 c = 20 print(solve(a, b, c))

## Input

40, 120, 20

## Output

True

- Related Articles
- Check if right triangle possible from given area and hypotenuse in Python
- Check if it is possible to create a polygon with a given angle in Python
- Check if it is possible to create a polygon with given n sidess in Python
- Check if it is possible to draw a straight line with the given direction cosines in Python
- Check if is possible to get given sum from a given set of elements in Python
- Check if it is possible to convert one string into another with given constraints in Python
- Check if it is possible to create a palindrome string from given N in Python
- Check if it is possible to form string B from A under the given constraint in Python
- Check whether triangle is valid or not if sides are given in Python
- Check if it is possible to reach a number by making jumps of two given length in Python
- Maximum area of rectangle possible with given perimeter in C++
- Prove that if two angles and one side of a triangle are equal to two angles and one side of another triangle. The triangles are congruent. Also check if the given pair of triangles are congruent?"
- Check if it is possible to serve customer queue with different notes in Python
- In an isosceles triangle, if the vertex angle is twice the sum of the base angles, calculate the angles of the triangle.
- Minimum height of a triangle with given base and area in C++

Advertisements