Sale!

COMP1405A/1005A “Introduction to Computer Science I” Assignment 5

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (5 votes)

Internet slang has entered (relatively) widespread usage, evolving from its roots as an
obfuscation technique into a form of communication used principally to express
dissatisfaction with the performance of a teammate or to caption photographs of
domesticated animals. For this assignment, you will write a program for something
resembling a 1337 (i.e., leetspeak) translator, that will receive a single sentence as a string
argument and produce a string return value for the equivalent sentence in 1337. If you are
not familiar with this “language”, read more at https://en.wikipedia.org/wiki/Leet.
For this assignment, you need to write a series of functions. Download (and rename) the
“starting_point_for_assignment_5.py” file from cuLearn, and add the required functionality:
• Write a main function that prompts the user to type a string and then remove all
punctuation marks and replace all lowercase letters with their uppercase equivalent
(using calls to the functions described below that you will write). Display this text to
the user and then ask…
o …if the user wants to replace phrases?
o …if the user wants to replace words?
o …if the user wants to replace letters and, if so, what letters?
Depending upon how the user responds to each question, you would then call some
or all of the functions described below (that you will write), printing the result after
each step. After printing the final result you must ask the user if they would like to
translate another string and, if the answer is yes, loop back to the input prompt. (n.b.,
Do NOT call the main() function again to achieve this repetition – use a loop.)
COMP1405A/1005A (Fall 2019)  “Introduction to Computer Science I”
Specification for Assignment 5 of 6
• Write a function to replace every lowercase character to its uppercase equivalent. You
may not use upper(), and your solution MUST use the ord() and/or chr() functions. If
you are not familiar with these functions, check the documentation at
https://docs.python.org/3/library/functions.html. You may not use functions like
encode or replace either – you are expected to use LOOPS to accomplish this
replacement. This function must take only the string to be modified as an
argument and must return the new string.
• Write a function to replace at least four different phrases (of two or three words) with
established acronyms (e.g., replace “BY THE WAY” with “BTW”) of your choosing.
This function must take only the string to be modified as an argument and must
return the string with the replacements. You may not use any built-in find, replace,
encode, or translate functions, but you may write your own version of these functions
if you wish, and you may use the indexing operator (i.e., the square brackets), the
slicing operator (i.e., the colon), the “in” operator, and the len() function.
• Write a function to replace at least four different words with established
abbreviations (e.g., replace “PLEASE” with “PLZ”) of your choosing. This function
must take only the string to be modified as an argument and must return the string
with the replacements. The restrictions (in terms of what you can and cannot use) are
the same as with the previous item.
• Write a function to replace at least eight different letters with established single or
double character homoglyphs (e.g., replace “K” with “|<“, “A” with “4”, “I” with “1”,
etc.) of your choosing. This function must take two arguments – the string to be
modified and a string of letters as an argument (i.e., the letters that the user decided
they wanted to replace). If any of those letters are among the eight different letters
you have coded homoglyphs for, your function must replace those letters with the
homoglyphs. If any of the letters passed as an argument are ones that you have not
coded homoglyphs for, print an explanation do the user (i.e., print a message like
“This program cannot translate the letter …”). This function must return the string
with the replacements. The restrictions (in terms of what you can and cannot user)
are the same as with the previous item.
• Make sure that every time you ask the user a yes or no question you validate that the
answer is yes or no (using any combination of uppercase and lowercase letters)
before proceeding. To clarify, if the user answers with something other than yes or
no, ask the question again.
• Please note that you cannot (for any reason) use global variables in the creation
of your submission for this assignment. Global constants, on the other hand, are
permitted.
On the following page, you can find a transcript example of how your program might appear
during execution (but of course the phrases, words, and letters your program replaces are
expected to be different).
COMP1405A/1005A (Fall 2019)  “Introduction to Computer Science I”
Specification for Assignment 5 of 6
Transcript Example (with user input in red)
n.b., for this example, the following replacements were selected by the programmer:
replace phrase “CAN I HAVE” with “I CAN HAZ” (if user chooses to replace phrases)
replace phrase “BY THE WAY” with “BTW” (if user chooses to replace phrases)
replace word “CHEESEBURGER” with “CHEEZBURGER” (if user chooses to replace words)
replace letter “A” with “@” (if user chooses to replace letters)
replace letter “E” with “3” (if user chooses to replace letters)
Type the string to be translated: By the way, can I have a cheeseburger?
BY THE WAY CAN I HAVE A CHEESEBURGER
Do you want to replace phrases? oops
Please enter yes or no. Do you want to replace phrases? yes
Do you want to replace words? Yes
Do you want to replace letters? YES
What letters do you want to replace? AEZ
This program cannot replace the letter ‘Z’.
String for translation BY THE WAY CAN I HAVE A CHEESEBURGER
After replacing phrases BTW I CAN HAS CHEESEBURGER
After replacing words BTW I CAN HAS CHEEZBURGER
After replacing letters BTW I C@N H@S CH33ZBURG3R
The translated string is ‘BTW I C@N H@S CH33ZBURG3R’.
Do you want to translate another string? nO
Goodbye.
This program (along with any other program submitted in this class) must be a completely
original work, authored by you and you alone, prepared for this offering (i.e., Winter 2019)
of COMP1005/COMP1405. Do not discuss this assignment with anyone except the instructor
or the teaching assistants, and do not copy source code samples from the internet or any
other source.