[SOLVED] 代写 R C data structure algorithm Scheme python graph statistic EMAT10007 – Introduction to Computer Programming

30 $

File Name: 代写_R_C_data_structure_algorithm_Scheme_python_graph_statistic_EMAT10007_–_Introduction_to_Computer_Programming.zip
File Size: 1092.72 KB

SKU: 0249523651 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


EMAT10007 – Introduction to Computer Programming
Assignment 1 – Building Programs Overview
• The objective of Assignment 1 is to submit an interactive Python program that allows the user to:
– Encrypt/decrypt messages using a Caesar cipher.
– Input the message to be encrypted/decrypted.
– Specify the rotation used by the Caesar cipher.
– Produce a list of statistics about the messages, such as letter frequency, average word length, etc.
• Your Python program should be accompanied by a short, 1-2 page report. This should discuss your implementation and any design choices. For example, why you chose to use a specific data structure or how you improved the reusability of your code.
• The deadline is 15:00 on Friday 15th November. You must upload your assignment including the program (.py) and report (.PDF) to Blackboard.
• For this assignment it is required that you submit individual work. You may discuss the creative approaches to solve your assignment with each other, but you must work individually on all of the programming.
Background: The basics of cryptography
• A Caesar cipher is a simple, well known cipher used in the encryption of strings. It is a ‘substitution cipher’, meaning that each letter is substituted with a corresponding letter in the alphabet at a predefined offset from the input letter’s position. The amount of offset is called rotation.
• The table below shows a Caesar cipher with a rotation value of 13; a popular special case of the Caesar cipher known as ROT13.
• In this example, the letter “A” is replaced by the letter indexed 13 positions to the right of “A”; the letter “N”.
• This particular cipher is only defined for the letters of the alphabet, meaning that punctuation, spaces, and numbers are left unchanged.
1
We
will
be
checking
for
plagiarism!
Index
0
1
2
3
4
5
6
7
8
9
10
11
12
13

Input
A
B
C
D
E
F
G
H
I
J
K
L
M
N

Output
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A

Part 1 – Encryption and decryption
1. Your program should ask for the following information: • The cipher mode
– Should it encrypt or decrypt the message? • A rotation value
– How far should the cipher shift?
– This should be a positive integer. • A message
– The words to be encrypted or decrypted.
– This should be able to take both single line and multi-line messages.
2. If no inputs are provided, or the provided input is incorrect, the program should provide instructions to the user before asking again.
3. When the cipher mode chosen is encryption then your program should encrypt the mes- sage by the provided shift by passing the message and rotation value to an encryption function as arguments. The program should then print the encrypted message.
4. When the cipher mode chosen is decryption your program should follow the same steps as above, except your program should call a decryption function on each message. Note that decryption follows the same process as encryption, only the shift goes the opposite way.
5. Numbers, punctuation and spaces should be unchanged.
6. All messages (either encrypted or decrypted) should be printed as UPPER CASE only.
Part 2 – Analysing messages
1. During the execution of your program, you should collect the following data on the plain
text (unencrypted English) message:
• Total number of words;
• Number of unique words;
• Minimum, maximum, and average word length;
• Most common letter;
• (Up to) The ten most common words and their frequency, e.g., the : 4 (i.e., ”the” has been found 4 times)
2. After the whole message has been encrypted or decrypted by your program, the program should print out the above statistics.
3. Thestatisticsshouldbebasedonthewholemessage;youdonotneedtoprintthemforeach line of the message.
Part 3 – Messages from a file
1. Modify your program so the user now has a choice between providing an input message or reading a message from a file.
2

2. If the user chose to read from a file, ask the user to provide a filename.
3. Theprogramshouldthenattempttoopenafilewiththenamegivenandreadinthecontents
of the file as the message.
4. If the filename provided cannot be found, the program should print an error with explana-
tion and ask again.
5. The program should then continue to work as before.
Part 4 – Automated decryption
1. Modify your program so that if the user has give the cipher mode as decryption, the user then has a choice between specifying a rotation value or choosing to automatically decrypt the message.
2. If automated decryption is chosen, the program should read in a file of common English words (this is provided by us and can be downloaded from BlackBoard).
3. The program should then attempt to automate the decryption process by implementing the following algorithm:
(a) Iteratively apply the decryption function to the first line of the message, incrementing the rotation by 1 each time.
(b) During every iteration, apply the decrypt function and attempt to match words in the decrypted line with words found in the common words list.
(c) If matches are discovered, then present the line to the reader, and ask if the line has been successfully decrypted:
i. If the user answers “no”, then continue to increment the rotation until the line is successfully decrypted.
ii. If the user answers “yes”, then print the rotation for this line, and start again at with the next line, until all the lines in the message have been successfully decrypted.
Note: The rotation value could be different for each line of the message.
Part 5 – (* Optional) Enhancements
The following section outlines some ideas to extend your program for those students confident with programming and looking to achieve additional marks. This section is strictly optional.
1. You may try to improve on the automated decryption process the following ways:
• Try out every possible rotation value first and sort them according to number of words matched with the dictionary. This should help reduce how many times you need to ask the user if the rotation is correct.
• Research and identify common patterns in the English language. Create a function which attempts to match these in the encrypted input message in order to identify the rotation without using the common words dictionary.
2. Add an alternative mode where the user can input random instead of a rotation value. This should then result in the encryption/decryption functionality described: Encryption:
3

(a) For each word in the message, you should select a rotation value at random, and then apply the rotation to the word.
(b) You should then append a random letter to the beginning of the encrypted word, and the letter rotation value positions down the alphabet to the end of the word. Example program input and output might be:
Please enter a message:“Hello world”
Output:AURYYBN EASVPHI
You may be able to work out that the first word uses a rotation of 13 (A → N) and the second word uses a rotation of 4 (E → I).
Decryption: Given that we now know the new encryption scheme, you should implement the decryption functionality for input encrypted using this new scheme.
Important: If you implement any enhancements to your program, you must comment them using the following format:
#!# Comment here …
as this will allow the TAs marking your project to easily locate your enhancements. An example comment might start like this:
#!# Here I create a set of common patterns in English to …
In the report, discussions related to your enhancements should go in a separate section.
Helpful hints and suggestions
• It is crucial that you complete all of the exercise sheets first – they have been specifically designed to prepare you for this assignment.
• You should spend plenty of time planning out how the flow of your program might look before you start programming. Look back at previous exercise sheets to see how to approach larger problems by breaking them down into smaller ones.
• Remember to think about the readability and reusability of your code. Some question you might ask yourself:
– Have I named things sensibly? Could someone pick up my code and understand it? – Am I repeating lots of code? Can I reuse any?
• Comment your code! Comments are something we haven’t discussed much up to this point, however they are crucial for many reasons:
– They help other readers to understand what your code is doing.
– They help you remember what your code is doing, when you come back to it weeks/months/years later. The whole point of writing code is that it can be reused many times, so to make
it reusable, add comments.
4

– To help your TA assess your understanding of the problem you are trying to solve, and to assess how well your solution solves it. If you use a data structure to implement some functionality, explain it in the comments.
Short comments are great to summarise the next several lines of code by giving a high-level overview. For longer, more detailed comments (likely useful in functions and for Part 4), by enclosing them in three speech marks “”” either side. E.g.
def SomeFunction(SomeArgument):
“””
This function does …
….and it does this….
“””
• We mark for the following points:
– Functionality: The more of the functionality described above you implement, the higher
the mark.
– Types: Proper use of data types and data structures.
– Comments: Appropriate and useful comments.
– Naming: Appropriate variable and function names (remember we want you to use Camel- Case)
– Report: Informative report, which explains your thought process
– Working code: Does the code do what it is supposed to? Is it robust, i.e., does it deal
correctly with wrong inputs (user/program interaction)
• Finally, don’t forget to ask for help! You will be able to ask your TA for help and advice during the lab sessions. There are also drop-ins on Mondays at 3pm in MVB 1.15 and the Support Forum on Blackboard.
5

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 R C data structure algorithm Scheme python graph statistic EMAT10007 – Introduction to Computer Programming
30 $