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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:30, jacob7542
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
image
Computers and Technology, 23.06.2019 05:30, savyblue1724707
Sally is editing her science report about living things. she needs to copy a paragraph from her original report. order the steps sally needs to do to copy the text to her new document.
Answers: 1
image
Computers and Technology, 23.06.2019 08:00, seaotter7140
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
image
Computers and Technology, 23.06.2019 18:00, bubbles173883
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a. edit the sizes and other characteristics of photos that have been inserted. b. take a screenshot of an image and copy it to the clipboard for pasting. c. search for drawings or other images from a library of prepared pictures. d. make illustrations using lines and shapes that are easy to manipulate.
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 in other subjects:

Konu
Mathematics, 06.01.2021 22:20
Konu
Biology, 06.01.2021 22:20
Konu
Mathematics, 06.01.2021 22:20