COSC1100 Assignment3 SecretCodes-Substitution
COSC1100 Assignment3 SecretCodes-Substitution
Prior to attempting this problem, you should have done the following:
1. View the Content, including assigned readings for weeks 5 through 9.
2. Viewed the Functions in Python video from week 9 and completed the associated Pre-Class Activity.
General Requirements
1. This assignment is to be completed individually. Group submissions will not be considered.
2. Analyze the problem, design a documented plan (i.e. flowchart or pseudo-code), code and test a solution
following the step-by-step approach presented in this course.
3. Submit your solution and plan to the appropriate assignment folder on DC Connect by the due date
provided.
4. Your instructor will assign a grade and post feedback on your submission to DC Connect.
Program Requirements
Create a simple Python application following the requirements below to allow a user to encode a piece of text
using a cipher, or to decode the text using the same cipher. A “cipher” is a method of making a coded message
that can be “deciphered” – usually the input to a cipher is the message to encode and some kind of “key” value
that makes it make sense.
In your program, after the user picks whether they are encoding or decoding the text, the user will enter text
and it will either be encoded or decoded. Since your program allows both encoding and decoding, you will be
able to (partly) test if the cypher works using just your own program.
Detailed Requirements:
• Initial prompt: When the program starts the user is prompted to enter “1” to encode, “2” to decode, or
“3” to exit.
• If the user inputs “1”:
o Accept one text input from the user; validation of this input may not be necessary
o Pass the user’s text input to an “encode” function
o Print the encoded text string that was returned by the “encode” function
o Do the initial prompt again
• If the user inputs “2”:
o Accept one text input from the user; validation of this input may not be necessary
o Pass the user’s text input to an “decode” function
o Print the decoded text string that was returned by the “decode” function
o Do the initial prompt again
• If the user inputs “3”:
o End the program
• If the user inputs anything other than “1”, “2” or “3”, re-prompt them with the initial prompt again.
Page 1 of 3
Assignment 3: Secret Codes (Arrays & Functions)
Assignment for COSC 1100 – Intro to Programming
Requirements for the Cipher Functions:
In this case, we will be using a Substitution cipher, which is a very simple type of cipher that operates by
replacing characters from one “alphabet” with the letters of another “alphabet”. In our case, we will convert
from English letters into the Al Bhed language from Final Fantasy X. Your encode and decode functions will each
have two parameters: the message, and a key value, where the key value represents how many times the
substitution cipher will run. The key will have a default value of 1.
Here is some partial pseudocode for the encode function that you can make use of:
Notably omitted from this code snippet is the key value. The entire substitution algorithm should run a number
of times equal to the key (which has a default value of 1). Each additional time it is encoded will “scramble” it
differently, and decoding it the same number of times will unscramble it.
Style Guide:
To be eligible for full marks on this or any assignment in this course your application must conform to the
requirements as outlined above as well as our prescribed style guide, in this case making sure to observe the
PEP8 naming conventions for Python as well as appropriate and complete program documentation.
Page 2 of 3
Assignment 3: Secret Codes (Arrays & Functions)
Assignment for COSC 1100 – Intro to Programming
Development Hints:
• As always, start with your planning steps. The pseudocode shown above may be part of the process and plan
(steps 3 and 4 of 10).
• Only after planning, consider how you can “translate” the given pseudocode into Python code.
• Ciphers are a very common programming exercise and thus there are numerous reference materials and
possibly even full solutions available on the web. However, be cautious with these!
o Make sure any “borrowed” code works and that your program actually meets our requirements.
o Make sure all code in your program conforms to our PEP8 style guide.
o Reference any code directly taken from an online resource or another person, or this will be
considered an incident of plagiarism. You can just do this in a comment before the part you have
taken from another source.
Sample Output:
Page 3 of 3