SHARE
TWEET

Python Hamming Code

naeem043 Feb 7th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top