Define and test a function to generate the binary sequence forthe input message. For example, if the input is “abc”, then thebinary sequence is 01100001 01100010 01100011 (97 98 99).
I need to program this in Python 3 asap please. Thank you.
Answer
PROGRAM (please ensure to keep indentation of code asshown in the screenshot)
def convertMessage(msg):
temp=0
array=[]
for i in msg:
temp = ord(i)
array.append(bin(temp))
return array
msg=input(“Type a message: “)
arr=[]
arr=convertMessage(msg)
print(“nThe binary sequence of the input message is”,end=”)
for j in arr:
print(“”,j,end=”)
SAMPLE OUTPUT:
Type a message:
OR
OR