0% found this document useful (0 votes)
5 views

4

The document outlines the requirements for Lab 1 of a Computer Science course, focusing on developing a program called ciphers.py for encrypting and decrypting messages. It includes instructions for setting up the Python environment, creating a project in PyCharm, and implementing the main and transform functions. Students must demonstrate reasonable effort during the in-lab activity to receive credit, and final submissions are to be zipped and uploaded to MyCourses by the due date.

Uploaded by

ashrith.mudundi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

4

The document outlines the requirements for Lab 1 of a Computer Science course, focusing on developing a program called ciphers.py for encrypting and decrypting messages. It includes instructions for setting up the Python environment, creating a project in PyCharm, and implementing the main and transform functions. Students must demonstrate reasonable effort during the in-lab activity to receive credit, and final submissions are to be zipped and uploaded to MyCourses by the due date.

Uploaded by

ashrith.mudundi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Science AP/X CSCI-140/242

Ciphers Lab 1: In-Lab Activity


1/14/2025

1 In-Lab Activity (10%)


During the in-lab time, you are expected to work on the assignment described below. At
the end of the time, you need to have either an SLI or instructor check off with you on the
progress you have made. Students who demonstrate having put in a reasonable amount of
effort will receive full credit for this component. Students who do not demonstrate reasonable
effort, leave early, or do not get verification, will not get credit.

2 Requirements
You will individually begin developing a program, ciphers.py, that can encrypt/decrypt
messages by applying transformation operations.

2.1 Starter Code


For the first part of this in-lab activity, you should work through the Python setup instruc-
tions and get the starter code configured with PyCharm.
Refer to the Python Setup instructions here:
https://www.cs.rit.edu/~f2y/Resources/python-setup.html
Once Python is setup, you should create a new project from the splash screen under Projects...New
Project. Select the directory on your home machine you want to store your project.
Next, get the starter code and example files by downloading them from:
https://www.cs.rit.edu/~csapx/Labs/01-Ciphers/code.zip
Extract the zip file, and then copy the input, output, and src directories into the root of
your project folder in PyCharm. To make PyCharm aware the src directory has source code,
you should right click on the src directory and select Mark directory as... Sources root.
The src directory should be blue color.
Your project structure should look as follows:

1
Verify that you can see the starter code ciphers.py in the src sub-directory. Run the
program by right clicking in the source code window. It should run but do nothing.

2.2 main function


This function runs the main loop that prompts the user to enter the following information
in this specific order:
• First, it prompts the user for the operation to perform: encrypt, decrypt or quit. The
user will type:
– E - for encrypting the message.
– D - for decrypting the message.
– Q - for terminating the program.
If the user enters Q, the program terminates gracefully. Otherwise, it will prompt the user
for:
• A message string to encode or decode. The format of the message will be all upper-case
letters (no spaces or punctuation).
• The set of transformation operations to apply on the message string.
It should then pass the operation to perform (encrypt or decrypt), the message and the
transformation operations to the transform function.

2.3 transform function


Write a function, transform, that takes a string message, a string of transformation opera-
tions and whether it must encrypt or decrypt the message. The final version of this function

2
will be in charge of encoding/decoding the message, but for now, it will just parse the string
of operations and print on the standard output the set of operations to apply in order. You
do not have to do anything with the message parameter yet. This function does not return
anything (you will change that later for the final lab implementation).
The format of the operation strings your program must process is as follows:

Table 1: Transformation operations


Operation String form Example
Si Si S0 S0
k −5
Si Si,k S2 S2,-5
R R R R
i −3
R Ri R R-3
Di Di D2 D2
k 3
Di Di,k D2 D2,3
Ti,j Ti,j T2,4 T2,4

To apply a set of operations over a message, they need to be separated by semicolons. So,
for example, if you were asked to encrypt the string HORSE given the transformation string
T2,4;S4;R you would generate the string SHOES.

2.4 Sample Run


Once you finished this in-lab assignment, the output should look similar to the following:
Welcome to Ciphers!
What do you want to do: (E)ncrypt, (D)ecrypt or (Q)uit? E
Enter the message: HORSE
Enter the encrypting transformation operations: T2,4;S4;R
Generating output ...
Transforming message: HORSE
Applying...
Operation Trade (T) - Parameters: 2,4
Operation Shift (S) - Parameters: 4
Operation Rotate (R) - Parameters:

What do you want to do: (E)ncrypt, (D)ecrypt or (Q)uit? E


Enter the message: CANAL
Enter the encrypting transformation operations: R2;D2;S2,9
Generating output ...
Transforming message: CANAL
Applying...
Operation Rotate (R) - Parameters: 2
Operation Duplicate (D) - Parameters: 2
Operation Shift (S) - Parameters: 2,9

What do you want to do: (E)ncrypt, (D)ecrypt or (Q)uit? D


Enter the message: SHOES
Enter the encrypting transformation operations: T2,4;S4;R
Generating output ...

3
Transforming message: SHOES
Applying...
Operation Rotate (R) - Parameters:
Operation Shift (S) - Parameters: 4
Operation Trade (T) - Parameters: 2,4

What do you want to do: (E)ncrypt, (D)ecrypt or (Q)uit? Q


Goodbye!

2.5 Commenting
You do not need to comment your program to receive the in-lab credit. If you finish early, it
is not a bad idea to begin documenting what you have written. You can look at the resources
section of the course web page to see a style example.

3 Submission
Because of the Monday holiday, the in-lab assignment that is normally due the prior Sunday
does not need to be submitted. Only the final submission will be graded. But the dropbox
is still open in MyCourses if you want to submit to it.
Go to your project’s src folder and zip it up. Rename the zip file to in-lab1.zip. Upload
this zip to the MyCourses In-Lab Assignment dropbox by the due date.
• To zip on Windows, right click on the src folder and select Send to -> Compressed
(zipped) folder.
• To zip on MacOS, right click on the src folder and select Compress "src".

You might also like