Gray to Binary and Binary to Gray conversion | Python3 code for above approach ; Driver code
def greyConverter ( n ) : NEW_LINE INDENT return n ^ ( n >> 1 ) NEW_LINE DEDENT n = 3 NEW_LINE print ( greyConverter ( n ) ) NEW_LINE n = 9 NEW_LINE print ( greyConverter ( n ) ) NEW_LINE