Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = input('Enter the data bit: ')
- p1 = int(data[3])^int(data[2])^int(data[0])
- p2 = int(data[3])^int(data[1])^int(data[0])
- p3 = int(data[2])^int(data[1])^int(data[0])
- codeword = data[0]+data[1]+data[2]+str(p3)+data[3]+str(p2)+str(p1)
- print("The parity bit is: ",p1,p2,p3 , "The codeword is: ", codeword)
- receive_data = input('Enter the receive data bit: ')
- count = 0
- if len(receive_data) == len(codeword):
- for i in codeword:
- if i != receive_data[count]:
- print('The error in position: ',count+1)
- break;
- count += 1
- else:
- print('Receive data bit size and send data bit size is not same')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement