- 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 whether right angled triangle is valid or not for large sides in Python
Suppose we have three sides in a list. We have to check whether these three sides are forming a right angled triangle or not.
So, if the input is like sides = [8, 10, 6], then the output will be True as (8^2 + 6^2) = 10^2.
To solve this, we will follow these steps −
- sort the list sides
- if (sides[0]^2 + sides[1]^2) is same as sides[2]^2, then
- return True
- return False
Let us see the following implementation to get better understanding −
Example Code
def solve(sides): sides.sort() if (sides[0]*sides[0]) + (sides[1]*sides[1]) == (sides[2]*sides[2]): return True return False sides = [8, 10, 6] print(solve(sides))
Input
[8, 10, 6]
Output
True
- Related Articles
- Check whether triangle is valid or not if sides are given in Python
- Check whether a string is valid JSON or not in Python
- How To Check if a Triangle is Valid or Not When Sides are Given in Java?
- Program to check whether given list is in valid state or not in Python
- Check whether the given sides of a triangle form a right angled triangle.$a = 9, b = 12$ and $c = 16
- Program to check whether a board is valid N queens solution or not in python
- The sides of the triangle are 10, 24, 26. Check whether this is a right triangle.
- Python program to check credit card number is valid or not
- Determine whether the triangle having sides $(a - 1) cm$, $2sqrt{a} cm$ and $(a + 1) cm$ is a right angled triangle.
- If the sides of a triangle are 3 cm, 4 cm, and 6 cm long, determine whether the triangle is a right-angled triangle.
- What is an scalene , equilateral , right angled triangle , obtuse angled triangle and a reflex angled triangle
- Check if any large number is divisible by 17 or not in Python
- Check if any large number is divisible by 19 or not in Python
- Check whether the given string is a valid identifier in Python
- Find the hypotenuse of a right angled triangle with given two sides in C++

Advertisements