Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do in python Part II: Encode Letter Differences (20 points) While solving this problem you will need to use the ord) function, which takes
Please do in python Part II: Encode Letter Differences (20 points) While solving this problem you will need to use the ord) function, which takes a character as its argument and returns an integer called its Unicode value. The Unicode value is the number used inside the computer's memory to store the character. For example, the uppercase letter A has the Unicode value 65, so ord('A') returns 65 As another example, the lowercase letter z has the Unicode value 122, so ord ('z' returns 122 Complete the function encode.steps, which takes one argument, message, a non-empty string of upper- case and lowercase letters. The function iterates over the message string one character at a time, computing the difference in Unicode code values between adjacent characters. More specifically, the code of the "earlier" character is subtracted from the code of the "later" character. For example, suppose we have the string "Worf", The respective Unicode values of these characters are 87, 111, 114 and 102. Therefore, the differences are 24 (24-111-87), 3 (3114 111) and -12 (-12 102 114). The returned string is assembled by inserting the Unicode differences between adjacent characters. Continuing this example, for the argument string 'Worf" the returned value would be the string 'W2403r-12f Note that the number of differences is one less than the number of characters. Therefore, if message contains only one character, the function should simply return message. Examples: Return Value S33t-5o-1nlly-55B48r-300o-4k U-2S Function Call encodesteps ('StonyBrook) encode.steps( US') encode.steps (') encode.steps(' VudcLg' encode.steps ('RqEHTLW encode.steps ('gTIEbN' encodesteps ('baTNdul) encode.steps(' OBcIVZub) encodesteps ('ismdbpkV) encode.steps (' DXLey') , V3 lu-17d-le-23L274, R31q-44E3H12T-8L11W 'g-19T241-39E29b-20N' b-1a-13T-6N22d17u-91 0-13B33c-26113V4227u-19b i10s-6m-9d-2b14p-5k-21V" "D20X-12L2 5e20y, Note: The quotation marks displayed in the example return values are there to emphasize that the return values are strings. You should not add quotation marks to your return values
Please do in python
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started