Write a Python Program to Convert Gray Code to Binary


Topic: Write a Python Program to Convert Gray Code to Binary

Solution

def gray_to_binary(n):
    """Convert Gray codeword to binary and return it."""
    n = int(n, 2)
 
    mask = n
    while mask != 0:
        mask >>= 1
        n ^= mask
    return bin(n)[2:]



List all Python Programs