Define Test Function Generate Even Parity Bit Input Message Example Input Bc Parity Bit 1 Q37020535

Define and test a function to generate the even parity bit forthe input message. For example, if the input is “bc”, then theparity bit will be 1 according to the message’s binary form01100010 01100011.

I need to program this in Python 3 asap please. Thank you.


Solution


SOURCECODE:

def test(message):
count=0
msg=[]
for c in message:
msg.append(str(dec_to_bin(ord(c))))
  
for c in msg:
for ch in c:
if(ch==’1′):
count=count+1;
if count%2==0:
return 0
else:
return 1
  

def dec_to_bin(x):
return int(bin(x)[2:])

main.py 1 def test(message): count-0 msg-[l for c in message: msg. append( (dec-to-bin( (c)))) #covert each char in Msg to bi

print(test(“bc”))

main.py 1 def test(message): count-0 msg-[l for c in message: msg. append( (dec-to-bin( (c)))) #covert

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.