Define Test Function Generate Binary Sequence Input Message Example Input Abc Binary Seque Q37020502

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=”)

1 def convertMessage(msg): temp-0 array L for l in msg: 3 4 temp ord(i) array.append(bin(temp)) 6 return arrav 9 msg-input(

SAMPLE OUTPUT:

Type a message:

OR
OR

Leave a Comment

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