w3resource

Python: Check whether three given lengths of three sides form a right triangle

Python Basic - 1: Exercise-34 with Solution

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

Pictorial Presentation:

Python: Check  wheather three given lengths of three sides form a right triangle

Sample Solution:

Python Code:

print("Input three integers(sides of a triangle)")
int_num = list(map(int,input().split()))
x,y,z = sorted(int_num)
if x**2+y**2==z**2:
    print('Yes')
else:
    print('No')

Sample Output:

Input three integers(sides of a triangle)
 8 6 7
No

Flowchart:

Flowchart: Python - Check  wheather three given lengths of three sides 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.



Follow us on Facebook and Twitter for latest update.