subject

Write a code block to encode strings into a secret message. Your code will presume a number, stored in key, and a message to encode, stored as a string variable called message. Don't define these variables in your code - they will be defined when you run the tests.
To do so:
Initialize a variable called encoded as an empty string
Use a for loop to loop across all characters of a string variable message
Inside the loop, convert the character to another character:
. Get the unicode code point for the character (using ord)
. Add the value of key to that code point (which should be an int)
. Convert this new int back to a character (using chr).
Also inside the loop, add this converted char to the string encoded
Note: You should not define key or message in your answer. Those are defined in the cell below where your code is executed (where you see %run)
In [ ] : %%writefile A2Code/encoder. py
# YOUR CODE HERE
raise NotImplementedError()
In : key -200
message-hello
%run -i . /A2Code/encoder .py
assert isinstance(encoded, str)
assert encodedij5k
print( Original Message: It', message)
print( Encoded Message: t', encoded)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:30
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
Which finger presses the h key on the keyboard? index finger on the left hand pinky finger on the right hand index finger on the right hand thumb on the left hand
Answers: 1
question
Computers and Technology, 24.06.2019 15:40
In the above figure, what type of cylinder arrangement is shown in the figure above? a. l-type b. v-type c. in-line d. horizontal pls make sure its right if its rong im grounded for 3months
Answers: 1
You know the right answer?
Write a code block to encode strings into a secret message. Your code will presume a number, store...
Questions
question
Mathematics, 23.10.2020 03:01
question
Mathematics, 23.10.2020 03:01
question
English, 23.10.2020 03:01
question
Mathematics, 23.10.2020 03:01
Questions on the website: 13722359