Check whether two numbers are in golden ratio | Function to check that two numbers are in golden ratio ; Swapping the numbers such that A contains the maximum number between these numbers ; First Ratio ; Second Ratio ; Condition to check that two numbers are in golden ratio ; Driver Code ; Function Call
def checkGoldenRatio ( a , b ) : NEW_LINE INDENT a , b = max ( a , b ) , min ( a , b ) NEW_LINE ratio1 = round ( a / b , 3 ) NEW_LINE ratio2 = round ( ( a + b ) / a , 3 ) NEW_LINE if ratio1 == ratio2 and ratio1 == 1.618 : NEW_LINE INDENT print ( " Yes " ) NEW_LINE return True NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE return False NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = 0.618 NEW_LINE b = 1 NEW_LINE checkGoldenRatio ( a , b ) NEW_LINE DEDENT