Advertisement
naeem043

Python Hamming Code

Feb 7th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. data = input('Enter the data bit: ')
  2. p1 = int(data[3])^int(data[2])^int(data[0])
  3. p2 = int(data[3])^int(data[1])^int(data[0])
  4. p3 = int(data[2])^int(data[1])^int(data[0])
  5. codeword = data[0]+data[1]+data[2]+str(p3)+data[3]+str(p2)+str(p1)
  6. print("The parity bit is: ",p1,p2,p3 , "The codeword is: ", codeword)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement