Python: Check whether three given lengths of three sides form a right triangle
Right Triangle Validator
Write a Python program to check whether three given lengths (integers) of three sides form a right triangle. Print "Yes" if the given sides form a right triangle otherwise print "No".
Input:
Integers separated by a single space.
1 ≤ length of the side ≤ 1,000
Visual Presentation:

Sample Solution:
Python Code:
Sample Output:
Input three integers(sides of a triangle) 8 6 7 No
Explanation:
Here is the breakdown of the above Python exercise:
- Prints a prompt asking the user to input three integers representing triangle sides.
- Takes the input as three space-separated integers, converts them to a list of integers.
- Sorts the list by assigning variables x, y, and z with the values of the sorted sides.
- Check whether the sorted sides form a Pythagorean triple (right-angled triangle) using the Pythagorean theorem.
- Prints 'Yes' if the sides satisfy the Pythagorean theorem, otherwise prints 'No'.
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to determine whether three given side lengths form a right-angled, acute, or obtuse triangle.
- Write a Python program to generate a list of Pythagorean triples up to a given limit.
- Write a Python program to verify if three sides can form a triangle and, if so, compute its area.
- Write a Python program to find all sets of three integers under 100 that form a right triangle.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to compute the digit number of sum of two given integers.
Next: Write a Python program which solve the specified equation.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.