Question: useing python Problem 1: Strings to numbers This problem will encode a way to go between strings of characters and integers. Since now we use
useing python

Problem 1: Strings to numbers This problem will encode a way to go between strings of characters and integers. Since now we use modern encryption techniques, we want to keep all the punctuation. However this means that we want to treat apostrophes and quotes as punctuation and not delimiters of strings. One way around this is to input all the strings using triple double quotes, e.g. A CAT!". Write a function str2num(s) that takes as input a string of characters, capitalizes it and returns the SAGE integer obtained by concatenating the corresponding ASCIll codes, e.g. str2num A cat) returns 53267658433 (a SAGE integer, not a string and not a Python integer!). (Note that capitalization ensures all ASCIll codes are two digit numbers. You may assume all punctuations in the input also have ASCII codes being two digit numbers so don't strip any of them.) b. Write a function num2str(m) that is the inverse of the function in (a), takes as input an integer and returns the corresponding message (capitalized), e.g. num2str(653267658433) returns 'A CAT! or "A CAT! c. Test your functions on the messageJust because it has always been done that way doesn't mean it's not incredibly stupid. done that way doesn't mean it's not incredibly stupid." and then num2str(a). That is, compute the number a st2num(" Just because it has always been Problem 1: Strings to numbers This problem will encode a way to go between strings of characters and integers. Since now we use modern encryption techniques, we want to keep all the punctuation. However this means that we want to treat apostrophes and quotes as punctuation and not delimiters of strings. One way around this is to input all the strings using triple double quotes, e.g. A CAT!". Write a function str2num(s) that takes as input a string of characters, capitalizes it and returns the SAGE integer obtained by concatenating the corresponding ASCIll codes, e.g. str2num A cat) returns 53267658433 (a SAGE integer, not a string and not a Python integer!). (Note that capitalization ensures all ASCIll codes are two digit numbers. You may assume all punctuations in the input also have ASCII codes being two digit numbers so don't strip any of them.) b. Write a function num2str(m) that is the inverse of the function in (a), takes as input an integer and returns the corresponding message (capitalized), e.g. num2str(653267658433) returns 'A CAT! or "A CAT! c. Test your functions on the messageJust because it has always been done that way doesn't mean it's not incredibly stupid. done that way doesn't mean it's not incredibly stupid." and then num2str(a). That is, compute the number a st2num(" Just because it has always been
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
