[SOLVED] R C Scheme python shell statistic mean: 3.55 median: 3.2 mode: [2.9, 3.2]

$25

File Name: R_C_Scheme_python_shell_statistic_mean:_3.55_median:_3.2_mode:_[2.9,_3.2].zip
File Size: 687.66 KB

5/5 - (1 vote)

mean: 3.55 median: 3.2 mode: [2.9, 3.2]
ITEM FREQUENCY
2.5 10
2.6 16
2.7 17
2.8 9
2.9 20
3.0 13
3.1 7
3.2 20
3.3 2
3.4 4
3.5 7 3.6 1 3.7 1 3.8 3 4.0 1 4.2 1 4.3 2 4.4 1 4.5 2 4.6 8 4.7 3
4.8 10
4.9 7
5.0 4
5.1 4
5.2 5
5.4 1
5.5 1
5.6 1
5.8 1
5.9 2
6.1 2
TCSS 380, Autumn 2019, Lab 7
The objective of this lab assignment is to give you a little practice with Python lists, dictionaries, strings, functions, and classes.
Work with a partner of your own choosing to complete this lab. You need to first two problems during the lab for full credit. At the end of the lab submit all the parts you complete during the lab session one submission per partnership.
If you do not complete some part within the two-hour session, finish at home by the designated due date. For this part, make sure that there is a comment at the top of your file that specifies whether you worked together or alone, and there is a name of your partner, if any. All together this lab involves:
rational.py
earthquakes.py encryption.py
1. Do you remember our rational number type from lab 3? You need to implement this ADT again, this time in Python. In the text editor of your choosing create a file rational.py and define class Rational, its properties and methods described below make sure you use the exact same names as indicated in the description. Test all methods below your class definition (i.e. in the same file)
a. constructor that takes two values to be used for numerator and denominator and assigns their values to private fields; the constructor should provide default values of 1 for these parameters
b. a class level field that counts the number of rational number objects
c. getters and setters for both the numerator and denominator
d. __str__method
e. __mul__ method that takes another rational object and returns self * param (if you name this
method correctly, then you overload the multiplication operator and in your test code, you can use something like object3 = object1 * object2
2. Download the program earthquakes.py. It is supposed to calculate statistics for the list of earthquakes provided in a text file. The statistics to calculate include the mean, the median, the mode, and the frequency table of all earthquake magnitudes. The shell for the code is written and you are not to change the shell itself you are to replace comments with code the comments that need to be replaced have numbers.
When the program is done, if ran on provided earthquakes.txt, it should produce the following statistics to the screen:
-1-

3. Download the program encryption.py. It is supposed to encrypt a phrase entered by the user using one of three encryption schemes: Caesar cipher, transposition cipher, or ASCII shift. The shell for the code is written and you are not to change the shell itself you are to replace comments with code the comments that need to be replaced have numbers.
Once you are done with filling everything in, add a loop that would allow the user to repeat the program.
Sample run:
Enter a message to encrypt: How are you 380?
Which encryption do you want to use?
Enter 1 for random Caeser cipher, 2 for transposition, 3 for an ASCII shift: 1
Random key:
abcdefghijklmnopqrstuvwxyz
fgdqntorhwzluecavibksjxpmy
The encrypted message is:rcx fin mcs 380
Repeat? Enter y to repeat or q to quit: y
Enter a message to encrypt: How are you 380?
Which encryption do you want to use?
Enter 1 for random Caeser cipher, 2 for transposition, 3 for an ASCII shift: 2
The encrypted message is:o r o 8?Hwaeyu30
Repeat? Enter y to repeat or q to quit: y
Enter a message to encrypt: How are you 380?
Which encryption do you want to use?
Enter 1 for random Caeser cipher, 2 for transposition, 3 for an ASCII shift: 3
Shift:7
H 72 79
o 111 118
w 119 126
32 39 a 97 104
r 114 121
e 101 108
32 39
y 121 128
o 111 118
u 117 124
32 39
3 51 58
8 56 63
0 48 55
? 63 70
The encrypted message is:Ov~hylv|:?7F
Repeat? Enter y to repeat or q to quit: q
Ciphers
Caesar cipher
Ceasars cipher is a type of substitution cipher in which each letter in plaintext is replaced by a letter from the key. For example, if the first row in the table below represents the alphabet string and the second one represents the key string, then the phrase such as dog, will become grj (d changes into g, o into r, and g into j).
alphabet key
The key can be generated by changing the order of the original alphabet characters in some way or by scrambling them in a random fashion. The example shown here deals with letters only, i.e. it does not account for digits, punctuation marks, etc. In the program, the function keyGen generates a random key, while caesar is supposed to create the encrypted message based on that key. keyGen is already complete but make sure you go over this code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
2

in order to understand it. Note that in our program letters are substituted as described by the table above, digits remain untouched (repeated as-is), and all other characters are substituted with spaces.
Transposition cipher
The transposition cipher is a type of a cipher that rearranges original characters in some fashion. In our case, it extracts all characters located at odd index values into one substring and all characters located at even index values into another string. Then, both strings get appended together (odds followed by evens).
ASCII shift
In this scheme, the phrase is encrypted by substituting original characters with new ones based on their ASCII values. The new character should be computed by taking the ASCII value of the old one and adding an integer to it, then converting this new numerical value back to character representation, i.e. new char = old_value + random_shift. The integer used for shifting during the particular program run should be decided at random.
CONGRATS YOU ARE DONE NO MORE LABS!!!!!!!!!!!!!!
3

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] R C Scheme python shell statistic mean: 3.55 median: 3.2 mode: [2.9, 3.2]
$25