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, 21.06.2019 20:50
What are the advantages of google cloud ?
Answers: 2
question
Computers and Technology, 22.06.2019 10:30
Think about a recent customer service experience - either positive or negative. write a brief summary of that experience. now think about those four characteristics we look for in customer service representatives. how did the representative in your example stack up? write down your answer and give specific examples.
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Which type of file can be used to import data into a spreadsheet?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
How do you take a green screen out of the video while editing?
Answers: 2
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, 01.12.2020 18:00
question
Chemistry, 01.12.2020 18:00
question
Mathematics, 01.12.2020 18:00
question
Computers and Technology, 01.12.2020 18:00
Questions on the website: 13722360