Question: using python to answer the question! A cipher is a procedure for encoding and decoding secret messages (or encrypted data). To work on this application,

using python to answer the question!
A cipher is a procedure for encoding and decoding secret messages (or encrypted data). To work on this application, we are going to need to use functions and operators. It also uses concepts and ideas from encoding and decoding - and in particular the operators ord and chr . 1 # Example / outline of writing a cipher 2 # The following shows a layout of writing a cipher. 3 # You will be writing code to actually do the encoding / decoding. 4 5 # Create a message 6 original_message 'Hello from Prof' 7 print('original Message:\t', original_message) 8 9 # First, Apply Encoding Code, to convert to an encoded message 10 encoded = 'jkj' 11 print('Encoded Message:\t', encoded) 12 13 # Then, Apply Decoding Code, to decode into an interpretable message 14 decoded = 'Hello from Prof' 15 print('Decoded Message:\t', decoded) Original Message: Encoded Message: Decoded Message: Hello from Prof ekjejf Hello from Prof Q13 - Decoder (0.25 points) Write a function decoder() to decode a secretly-encoded character back to its original character. Your function will take two parameters: encoded_char | The enoded character to be decoded (str) key | The key to be used during encoding (int; default: 200) Within the function, convert encoded_char back to char by: Getting the unicode code point for encoded_char (using ord) Subtracting the value of key from that code point (which should be an int) This undoes the secret encoding of the character, getting back to the original value Convert this new int back to a character (using chr). The decoded character should be stored in char , which should be return ed from the function. Note that the code to answer this question should look very similar to how you answered the encoding question. In fact, you can even copy over the encoding code, and make some small changes to make it function as a decoder. 1 # YOUR CODE HERE 2 raise Not ImplementedError() 1 # you can use this cell to test/execute/check your thinking (optional) 1 # tests decoder with default key value 2 assert decoder('i') == 'h' 3 assert decoder('i') == 'e' 4 assert decoder('9') == 'i' 5 assert decoder('j') == 'l' 6 assert decoder('') == 'o' 1 # hidden test to check for functionality with other values for key
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
