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:])
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