Python Lab 2: Algorithmic Encryption
Due Tuesday, September 14th, by 11:45pm
Introduction
Welcome to your second week of Python in CSCI 101 - just ONE lab this week!
You should submit this lab as a single .py file. For those NOT
in CSCI 102, check out the CSCI 102 Schedule to see
what was covered this week (if needed).
To get started, open IDLE and then create a New File via the File menu. We
suggest you immediately save this file in some directory you create that you will use to
store/manage all
your Python Labs this semester (e.g., CSCI101/PythonLabs). Save this file as
Lab2-alg_encrypt.py.
Assignment
A module we will cover later this semester in CSCI 101 is on cybersecurity. For this lab, suppose you want to send a secret message
to your friend. The two of you decide upon an algorithm to encrypt the data, so that
the end result would not be easy to read by others. The goal of this lab
is to encrypt a message in the following way.
Given five lists of characters (which are also known as strings), transform and concatenate the lists to form an encrypted message such that:
- The first list of characters should be "rotated right 2", which means the last two characters in the string should
be moved to the front of the string. Example: "Hello" -> "loHel". (You can assume the string length will be at least 2.)
- The second list of characters should not contain the last two characters given. Example: "coding" --> "codi"
- The third list of characters should contain only the second half of the string. (You can assume the length
of the string is even.)
Example: "CSCI101C" -> "101C".
- The fourth list of characters should swap the 3rd character with the 5th character. Example: "Tracy" -> "Tryca". (You can assume the string length will be at least 5.)
- The last list of characters should contain the tags that enclose the entire message.
For example, if the enclosure tag provided is "<<>>" , the entire concatenated message will be
<< loHelcodi101CTryca >>.
(Include a space before and after the encrypted message.) You can assume the length of the tag is always four.
Lab I/O Format
For lab assignments this semester, a specific Lab
Input/Output Format is required. This format
is described below:
- When prompting for input, use the prompt string
WORD> , where WORD
is a single, uppercase word which describes the input. For
example, this lab might choose: LIST1> ,
LIST2> , etc.
- When providing output that will be graded, start the line
with the word
OUTPUT followed by exactly one space, e.g. OUTPUT .
Think of this as "boxing your answer" on a math worksheet; it lets us quickly
find your answer. Gradescope will skip any output
lines that do not start with OUTPUT .
- You are welcome to have other output lines that do not
begin with OUTPUT; Gradescope
will ignore these.
- A submission without exactly correct output formatting will receive an AUTOMATIC ZERO.
This is because Gradescope is automated—it does not look at your code, only the results, and thus
the format of the results must be consistent for all students.
Example Execution
Input the five lists of characters to be encrypted.
LIST1> Hello
LIST2> coding
LIST3> CSCI101C
LIST4> Tracy
LIST5> <<>>
The encrypted message is:
OUTPUT << loHelcodi101CTryca >>
Gradescope Submission Nuances
When you submit your Python file to Gradescope, multiple different test
cases are run on your code. Passing all of the tests results in a 100% on
the autograded portion of the lab. You are allowed to submit to Gradescope four
times (or less) for this lab. The maximum grade of your submissions will be your grade for
the lab. Note: If your code doesn’t work (e.g., a syntax error exists,
or an error is thrown in execution), then you will received an AUTOMATIC ZERO. You
should test your code before submitting to ensure it executes correctly.
Comments
All Python files should include a header with your name,
section, assignment info, references (i.e., who did you collaborate
with on this assignment?; what resource did you use?), and approximate
time taken to do the assignment. Be sure to cite any
allowed external references used to complete the assignment.
Any code without this header will lose 1 point. Here's an
example:
# Tracy Camp
# CSCI 101 – Section B
# Python Lab 2
# Reference: my friend (Tom Hanks) taught me how to move characters in a list
# Reference: TA Carter helped me debug my code
# Time: 45 minutes
Submission
Once you are satisfied with your solution to this lab, you need to
submit the file to Gradescope. In Gradescope, go to Assignments > Lab2
and upload Lab2-alg_encrypt.py.
Note: this lab is worth 4 points. To receive credit, your code must execute in Python 3,
you must submit a single file (your Python code file), and you
must have the input/output match the lab requirements.
Whenever you submit something to Gradescope, we strongly recommend you always double check
what you submitted actually got submitted correctly (e.g., did the file upload correctly?
did you submit the correct file? etc.) If your submission is incorrect, it's on you.
|