首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
EMAT10007编程设计辅导、辅导Python编程、Programming程序语言讲解 讲解R语言编程|解析Java程序
项目预算:
开发周期:
发布时间:
要求地区:
EMAT10007 – Introduction to Computer Programming
Assignment 2020 – Encrypted Information
Overview
• The objective of the assignment 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.
– Extract statistics about the messages, such as letter frequency, maximum word length.
– Automate the identification of the rotation needed to decipher an encrypted message.
• Your Python program should be accompanied by a short, 1-2 page report, submitted as a
.pdf file. 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 re-usability of your code.
• 100 marks in total are available:
– 85 marks for the Python program (includes 5 marks for general Python implementation)
– 15 marks for the report
• The deadline is 13:00 on Friday 11th December (GMT). You must upload your
assignment including the program (.py), report (.pdf) and any additional files generated by
or needed to run your program (e.g. .txt files) to Blackboard. You can find the submission
point under Assessment, Submission and Feedback.
• You must show which part of the assignment each section of your code answers by adding
comments showing part and sub-section (e.g. Part 1.1) using the following format :
# PART 1.1 Comment here ...
Note that the order that the answers to the questions appear in the code may be different to
the order they appear in this document so it is important to indicate to the marker where
you have attempted to answer each question.
Some blocks of the code may include the answer multiple questions. Make sure you indicate
this in your comments where applicable. Your comments should tell the reader what your
code does, in addition to indicating which question you are answering.
• This is an individual project. You may discuss the creative approaches to solve your assignment
with each other, but you must work individually on all of the programming. We will
be checking for plagiarism!
1
Helpful hints and suggestions
• Complete all of the exercise sheets first - they have been designed to prepare you for this
assignment.
• You should spend plenty of time planning the flow of your program 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 questions
you should 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?
– Can I simplify the layout of my code to make it more readable?
• You will gain marks for:
– Types: Appropriate use of data types and data structures.
– Comments: Concise, clear and useful comments.
– Naming: Appropriate variable and function names
– Working code: Does the code do what it is supposed to? READ THE QUESTIONS
CAREFULLY to check. Is the program robust, i.e., does it deal correctly with wrong
inputs (user/program interaction).
– Concise, efficient code e.g. use of functions, list comprehensions, imported functions
from Python packages.
– More advanced programming techniques such as use of classes and user-defined libraries
stored as separate .py files.
– Report: Informative report, which explains your thought process and analyses the choices
you made in your code design. You must reference any external code or ideas used.
• Finally, don’t forget to ask for help! You will be able to ask your TA for help and advice
during the weekly drop-in sessions and tutorials.
Programming Tips and Hints
• ASCII (American Standard Code for Information Interchange), is a character encoding used
to represent text (letters and other characters) as numbers https://www.ascii-code.com/.
Upper and lower case alphabet letters, for example, are represented by numbers in the range
65-90 and 97-122 respectively. Punctuation marks, spaces etc also have ASCII encodings.
Python ord() and chr() are built-in functions that can be used to convert from a string
character to the number used to represent it in ASCII (ord()) and from a number from the
set used in ASCII the character it represents (chr()).
2
• The built-in Python function sorted(), returns a sorted list of items in an iterable (e.g. a
list). If each item is a tuple, sorted() will sort the tuples using the first element in each
tuple.
So to sort multiple data structures, using the order of one of them, first re-organise the
data-structures into a data structure, where each element is a tuple.
https://docs.python.org/3/howto/sorting.html
3
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 size of the offset is
called the 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.
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 ...
• 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.
4
Part 1 - Encryption and Decryption [Total: 20 marks]
1. Your program should ask the user for the following information:
• The cipher mode : encrypt or decrypt the message
• A rotation value : number of places (positive or negative) the cipher should shift
each character.
• A message : the text to be encrypted/decrypted.
The only actions required of the user to operate the cipher should be to:
(i) run the python program
(ii) provide these three inputs when prompted
2. If no inputs are provided, or the provided input is incorrect, the program should prompt the
user for the inputs again.
3. When the cipher mode chosen is encrypt then your program should encrypt the message
given by the user using the rotation given by the user.
4. When the cipher mode chosen is decrypt your program should decrypt the message given
by the user using the rotation given by the user. (Note that decryption follows the same
process as encryption, only the shift goes the opposite way.)
5. The program output should be to print the encrypted message if the cipher mode is encrypt
and the decrypted message if the cipher mode is decrypt.
Numbers, punctuation and spaces should be left unchanged.
All messages (either encrypted or decrypted) should be returned as UPPER CASE only.
6. Modify your program so that the user may select to use a random number as the rotation
value. If the user selects to use a random number, the cipher will shift the text by a number
of places equal to a random number generated by the program. Note, the option for the
user to specify the rotation value explicitly must remain in the program.
Part 2 - Analysing Messages [Total: 25 marks]
1. In this exercise, the definition of a word is a collection of characters with a space at the
leading and trailing end of the characters, excluding any numbers and punctuation marks.
• python is a word
• 123 is not a word
• py8thon should be interpreted as the word python
• python! should be interpreted as the word python
During the execution of your program, you should collect the following metrics on the plaintext
(unencrypted English) message:
(a) Total number of words.
(b) Number of unique words.
(c) (Up to) The ten most common words sorted in descending order by the number of
times they appear in the message. In other words, if there are ten or fewer words in
total in the message, sort all words in the message, but if there are greater than ten
5
words in total, select only the ten most common words to sort.
(Note: If multiple words appear in the message the same number of times, this may
result if two or more words being the tenth most common. In this case your program
should limit the set of words to show only ten of the most common words.)
Hint: The built-in Python function sorted() returns a sorted list of items in an iterable
(e.g. a list). If each item in the list is a tuple, sorted() will sort the tuples by
comparing the the first element of each tuple, and if it’s equal the second, and so on.
So to sort multiple data structures, using the order of one of them, first reorganise
the data-structures into a data structure, where each element is a tuple.
https://docs.python.org/3/howto/sorting.html
(d) Minimum and maximum word length.
(e) Most common letter (Remember to exclude spaces and punctuation marks!).
Hint: Be careful of punctuation when checking for unique words (e.g. ‘hello’, and
‘hello,’, may be incorrectly interpreted as two different words due to the comma in the
second word). You may need to disregard punctuation to correctly count the number of
unique words.
2. After the whole message has been encrypted/decrypted by your program, and the encrypted/decrypted
message has been printed (Part 1), the program should print out the
above statistics.
The most common words sorted in descending order (Part 2, Question 1c) should be printed
with the following format:
the : 4
(i.e. ‘the’ has been found 4 times)
3. The program should save the metrics:
• total number of words
• number of unique words
• minimum word length
• maximum word length
as a .txt file. Each metric should appear on a new line. The name of the metric followed by
the value should appear in the file e.g. total number of words followed by the value:
total number of words: 57
Part 3 - Messages from a File [Total: 5 marks]
1. Modify your program so that before asking the user to input the message the user is
prompted to select a message entry mode:
(a) manual entry : typing in a message to encrypt/decrypt;
(b) read from file : specifying a text file, the contents of which will be encrypted/decrypted;
2. If the user chooses manual entry, the message should be typed in, as before.
If the user chooses read from file, the user should provide a filename (including file
6
path) when prompted for the message.
The prompt shown to the user when they are asked to input the message should indicate
these requirements.
3. If the user chooses read from file, the program should attempt to open a file with the
name given and read in the contents of the file as the message.
4. If the filename provided cannot be found, the program should print an error and ask again.
The program should then continue to work as before.
Part 4 - Automated Decryption [Total: 15 marks]
1. Modify your program to include an additional auto-decrypt option for cipher mode.
2. If auto-decrypt is chosen, the program should read in words.txt, a file of common English
words (this is provided and can be downloaded from BlackBoard).
3. The program should then attempt to automate the decryption process by implementing the
following algorithm:
(a) Iterate through all possible rotations, applying the rotation to the first line of the
message.
(b) During each iteration:
(i) attempt to match words in the rotated first line with words found in the common
words list.
(ii) If one or more matches are discovered, then present the line to the reader, and ask
if the line has been successfully decrypted:
(iii) • If the user answers “no”, then continue to iterate until the first line is successfully
decrypted.
• If the user answers “yes”, then apply the successful rotation to decrypt the rest
of the file.
(c) In the case that no successful decryption is found, the program will be unable to collect
the metrics (Part 2) on the plaintext message. You should account for this in your
code and ensure that, if no match is found, the program skips collecting the metrics
and printing the decrypted message, and continues to work.
Part 5 - (* Optional) Enhancements [Up to 15 marks]
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 optional!
Important:
If you implement any enhancements to your program, you must comment them using the following
format:
#!EXTRA# Comment here ...
as this will allow the TAs marking your project to easily locate your enhancements. An example
comment might start like this:
7
#!EXTRA# Here, a bar chart is generated ...
If you implement any enhancements to your program, that modify your answers to Parts 1-4 you
must make a copy of your original answer so that it can be marked (for example, comment out your
original answer so that it can still be seen or submit the modified program as a separate Python
file).
In the report, discussions related to your enhancements should go in a separate section.
1. Suggestions for using metrics collected on the data:
• Produce a bar chart showing (up to) the ten most common words (Part 2) on the
horizontal axis and the number of times they appear in the message on the vertical
axis.
• Save the plot as a .pdf file.
2. Suggestions for improving the encrypt process:
• Modify the encrypt process so that for each line in the message, a new rotation value
is selected at random, then applied to the line (update decrypt to decrypt line by line).
3. Suggestions for improving the auto-decrypt process:
• Modify the program to try every possible rotation value and sort the solutions according
to the number of words matched with the list of common words in words.txt.
The program should select the solution with the greatest number of matched words
as the decrypted solution. If there is a tie between more than one solution regarding
the number of words matched, the program should present the solutions to the user to
identify which is correct.
(This can help reduce how many times you need to ask the user if the rotation is
correct).
8
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!