Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribedimage text in transcribed 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago