(Python-GColab IDE) Instructions: Make a program that turns the 8-bit data into the 12-digit codeword. The code should figure out what the four parity bits are and put them in the right places in the codeword.
The input could be a single letter, which could be in uppercase or lowercase. The output is the 12-digit codeword and the 3-letter hexadecimal equivalent of the codeword.
Note: (Even Parity, 12 number of bits, 4 bit parities, 8-data bits(add 0 at the left to make 8)
My Question:
Can I ask if how can I get the four bit parity given a character? I have my code already but I'm stuck in that part. My partial code is below.
x = True
while(x==True):
ASCII_input = str(input("Input a character: "))
if (ASCII_input) == 1:
ASCII_input = input("Input a correct character ")
else:
break
ASCII_code = ord(ASCII_input) #Char to ASCII
print("The ASCII value of " + ASCII_input + " is", ASCII_code)
#ASCII to 8 bit binary
bnr = bin(int(ASCII_code)).replace('0b','')
x = bnr[::-1] #this reverses an array
while len(x) < 8:
x += '0'
bnr = x[::-1]
print(bnr)