Question
Programming Exercise 4.7 Write A Script That Decrypts A Message Coded By The Method ... Question: Python Programming Exercise 4.7 Write a script that decrypts
Programming Exercise 4.7 Write A Script That Decrypts A Message Coded By The Method ... Question: Python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used i... python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: Add 1 to each characters numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter the coded text: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101 Hello world!
def bits2string(b=''): return chr(int(b, 2) - 1) def shift(n=''): temp = list(n) new = (temp[-1:] + temp[0:-1]) ret = "" for i in new: ret = ret + i return ret coded = input("Enter the coded text: ") process = coded.split(" ") decoded = "" for q in process: decoded = decoded + bits2string(shift(q)) print " Decoded Information: " + decoded
im getting the error "SyntaxError: 'return' outside function"
Programming Exercise 4.7 Instructions Write a script that decrypts a message coded by the method used in Project 6 Llil Method used in project 6: s/p 1. Add 1 to each character's numeric ASCII value 2. Convert it to a bit string 3. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter the coded text: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 Hello world! Grading When you have completed your program, click the Submit button to record your scoreStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started