Note: You should complete this assignment in identified pairs (not more than two students). You should submit your assignments separately, but you will receive the same grade as your partner. You may do this assignment by yourself, if you are so inclined…but then you cannot discuss the homework with any other students (or reference any other students in your header).
You will write a python program that uses a variation of the simple, well-known PIG LATIN cypher to encrypt (and decrypt) a message. To accomplish this, you will write three functions inside a file called hmwk6.py
:
- The
encrypt(...)
function will take in a string and perform the following operations:
- Split the string into individual words
- Add an asterisk (*) to the end of the word.
- For each word, move all the letters before the first vowel (A,E,I,O,U) to the end of the word. If the word begins with a vowel or does not contain any vowels (e.g., my), simply append the letters ~W.
- Add the letters “AY” onto the end of each word.
- Join all the modified words back together into a single string and return it.
- Example: “COMPUTER SCIENCE IS GREAT” –> “OMPUTER*CAY IENCE*SCAY IS*~WAY EAT*GRAY”.
The decrypt(...)
function should do the inverse (i.e. it should undo the encrypt() function’s modifications and recover/return the original message).
- The
main(...)
function should then do the following:
- Ask the user to input a message.
- Convert the message to CAPS (so we don’t have weird capitalization in the end).
- Call the
encrypt(...)
function on the message and return the encrypted string.
- Print the encrypted string in main().
- Call the
decrypt(...)
function on the encrypted message and return the decrypted string.
- Print the decrypted string in main().
Grading criteria (10 points):
Style points (2 points)
The submission:
- includes a header including both partners’ names, the filename, and any references
- uses appropriate, informative variable names
- is called
hmwk6.py
and runs without syntax errors
- is accompanied by a completed self-evaluation by the author
Operations (8 points)
The program:
- correctly defines and calls both
encrypt(...)
and a decrypt(...)
functions from main()
.
- has a
main()
function that runs when we execute hmwk6.py
but not if we import it.
- has an
encrypt(...)
function that correctly transforms the input message (3 pts.).
- has a
decrypt(...)
function that correctly recovers the original message (3 pts.).
Submissions
Your submission must include the course header at the top.
Last Submission March 10, 2020 at 10:00PM (EST). Go to our Moodle page. Submit your hmwk6.py
file and fill out your self-assessment.