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 procedurefor encoding and decoding secret messages (or encrypted data). To work on 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 Write a function custom_encoder() to encode a character from original messages, using our custom encoding scheme (defined below). This function should take two input parameters: char the character to be encoded using our custom encoding scheme key the key to be used in encoding (int; default: 200) Within the function, carry out the following: Define the dictionary custom_encodings (provided at end of this cell) If char is a key in the custom_encodings dictionary, store the corresponding value from the dictionary in output_char (i.e. if char were 'o', the function would return 'n') Otherwise, use the encoder() function you wrote earlier, storing the output in output_char , being sure to pass both char and key in as inputs. Be sure to return the encoded character (output_char ) from the function custom_encodings = { a' 'r', e 'p', 'm', 'o : u' : 's } 'n 1 2 # YOUR CODE HERE raise NotImplementedError() 1 2 # test for char in custom_encodings custom_encoded = custom_encoder('a') assert type (custom_encoded) == str assert custom_encoded =- 'r' 3 4 5 1 2 # tests for char not in custom_encodings & variable key custom_encoded = custom_encoder('A') assert type (custom_encoded) == str assert custom encoded == 'C' 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!