Write a Python function to convert binary to Gray codeword


Topic: Write a Python function to convert binary to Gray codeword

Solution

def binary_to_gray(n):
    n = int(n, 2)
    n ^= (n >> 1)
    return bin(n)[2:]
 
 
 



List all Python Programs