Check if a right | Python3 program to implement the above approach ; Function to check if N is a perfect square number or not ; If N is a non positive integer ; Stores square root of N ; Check for perfect square ; If N is not a perfect square number ; Function to check if given two sides of a triangle forms a right - angled triangle ; If the value of ( A * A + B * B ) is a perfect square number ; Update checkTriangle ; If the value of ( A * A - B * B ) is a perfect square number ; Update checkTriangle ; If the value of ( B * B - A * A ) is a perfect square number ; Update checkTriangle ; Driver Code ; If the given two sides of a triangle forms a right - angled triangle ; Otherwise
from math import sqrt , floor , ceil NEW_LINE def checkPerfectSquare ( N ) : NEW_LINE INDENT if ( N <= 0 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT sq = sqrt ( N ) NEW_LINE if ( floor ( sq ) == ceil ( sq ) ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 0 NEW_LINE DEDENT def checktwoSidesareRighTriangle ( A , B ) : NEW_LINE INDENT checkTriangle = False NEW_LINE if ( checkPerfectSquare ( A * A + B * B ) ) : NEW_LINE INDENT checkTriangle = True NEW_LINE DEDENT if ( checkPerfectSquare ( A * A - B * B ) ) : NEW_LINE INDENT checkTriangle = True NEW_LINE DEDENT if ( checkPerfectSquare ( B * B - A * A ) ) : NEW_LINE INDENT checkTriangle = True NEW_LINE DEDENT return checkTriangle NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = 3 NEW_LINE B = 4 NEW_LINE if ( checktwoSidesareRighTriangle ( A , B ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT