SlideShare a Scribd company logo
1 of 16
For any Assignment related queries, Call us at : - +1 678 648 4277
You can mail us at :- support@pythonhomeworkhelp.com or
reach us at :- https://www.pythonhomeworkhelp.com/
Part A: Permutations of a string
A permutation is simply a name for a reordering. So the permutations of the string
‘abc’ are ‘abc’, ‘acb’, ‘bac’, ‘bca’, ‘cab’, and ‘cba’. Note that a sequence is a
permutation of itself (the trivial permutation). For this part of the pset you’ll need to
write a recursive function get_permutations that takes a string and returns a list of all
its permutations. You will find this function helpful later in the pset for part C.
A couple of notes on the requirements: Recursion MUST be used , global variables
may NOT be used. Additionally, it is okay to use loops to code the solution. The order
of the returned permutations does not matter. Please also avoid returning duplicates in
your final list.
Suggested Approach
In order to solve any recursive problem, we must have at least one base case and a
recursive case (or cases). We can think of our base case as the simplest input we could
have to this problem (for which determining the solution is trivial and requires no
recursion) -- for this approach, our base case is if sequence is a single character
(there’s only one way to order a single character).
pythonhomeworkhelp.com
If sequence is longer than one character, we need to identify a simpler version of the
problem that, if solved, will help us easily find all permutations for sequence . The
pseudocode below gives one approach to recursively solving this problem.
Given an input string sequence :
●Base case:
○if sequence is a single character, there’s only one way to order it
■return a singleton list containing sequence
●Recursive case:
○suppose we have a method that can give us a list of all permutations of all but
the first character
in sequence (Hint: think recursion)
○then the permutations of all characters in sequence would be all the different
ways we can insert the first character into each permutation of the remaining
characters
■example: if our word was ‘bust’, we hold out the character ‘b’ and get the list
[‘ust’, ‘sut’, ‘stu’, ‘uts’, ‘tus’, ‘tsu’]
●then ‘ust’ gives us: ‘b ust’, ‘ub st’, ‘us b t’, ‘ust b ’
●‘sut’ gives us: ‘b sut’, ‘s b ut’, ‘su b t’, ‘sut b ’
●and so on …
pythonhomeworkhelp.com
Implement the get_permutations(sequence) function found in ps4a.py
according to the specifications in the docstring. Write three test cases for
your function in comments under if __name__ == ‘__main__’ . Each test
case should display the input, expected output, and actual output. See the
if __name__ == ‘__main__’ for an example.
Part B: Cipher Like Caesar
Ever want to relive the glory days of your youth and pass secret messages to your
friends? Well, here is your chance! But first, here is some vocabulary:
●Encryption - the process of obscuring or encoding messages to make them
unreadable
●Decryption - making encrypted messages readable again by decoding them
●Cipher - algorithm for performing encryption and decryption
●Plaintext - the original message
●Ciphertext - the encrypted message. Note: a ciphertext still contains all of the
original message information, even if it looks like gibberish.
pythonhomeworkhelp.com
Caesar Cipher
The idea of the Caesar Cipher is to pick an integer and shift every letter of your
message by that integer. In other words, suppose the shift is kth . Then, all instances
of the i letter of the alphabet that appear in the plaintext should become the (i + k) th
letter of the alphabet in the ciphertext. You will need to be careful with the case in
which i + k > 26 (the length of the alphabet).
We will treat uppercase and lowercase letters individually, so that uppercase letters
are always mapped to an uppercase letter, and lowercase letters are always mapped to
a lowercase letter. If an uppercase letter maps to “A”, then the same lowercase letter
should map to “a”. Punctuation and spaces should be retained and not changed. For
example, a plaintext message with a comma should have a corresponding ciphertext
with a comma in the same position.
Examples:
Plain text sift ciphertext
‘abcdef’
‘Hello, World!’
‘’
2
4
any value
‘cdefgh’
‘Lipps, Asvph!’
‘’
pythonhomeworkhelp.com
Classes and Inheritance
This is your first experience coding with classes! Get excited! We will have a
Message class with two subclasses PlaintextMessage and CiphertextMessage .
Message contains methods that could be used to apply a cipher to a string, either to 3
encrypt or to decrypt a message (since for Caesar codes this is the same action).
PlaintextMessage has methods to encode a string using a specified shift value; our
class will always create an encoded version of the message, and will have methods
for changing the encoding. CiphertextMessage contains a method used to decode a
string.
When you have completed your implementation, you can either create a
CiphertextMessage instance using an encrypted string that someone provides you
and try to decrypt it; or you can encrypt your own PlaintextMessage instance, then
create a CiphertextMessage instance from the encrypted message within the
PlaintextMessage instance, and try to decrypt it and see if it matches the original
plaintext message.
Your job will be to fill methods for all three of these classes according to the
specifications given in the docstrings of ps4b.py . Please remember that you never
want to directly access attributes outside a class - that’s why you have getter and
setter methods. pythonhomeworkhelp.com
Don’t overthink this; a getter method should just return an attribute and a set
method should just set an attribute equal to the argument passed in. Although they
seem simple, we need these methods in order to make sure that we are not
manipulating attributes we shouldn’t be. Directly using class attributes outside of
the class itself instead of using getters and setters will result in a point deduction –
and more importantly can cause you headaches as you design and implement object
class hierarchies.
Rules
You do not have to use recursion in Part B, but you are welcome to. There are a
couple of helper functions that we have implemented for you: load_words and
is_word . You may use these in your solution and you do not need to understand
them completely, but should read the associated comments. You should read and
understand the helper code in the rest of the file and use it to guide your solution.
Part 1: Message
Fill in the methods of the Message class found in ps4b.py
according to the specifications in the docstrings.
pythonhomeworkhelp.com
We have provided skeleton code in the Message class for the following functions -
your task is to implement them. Please see the docstring comment with each function
for more information about the function specification.
●__init__(self, text)
●The getter methods 4
○get_message_text(self)
●Note: This should return an immutable version of the message text we added to this
object in init. Luckily, strings are already immutable objects, so we can simply return
that string.
○get_valid_words(self)
●Note: this should return a COPY of self.valid_words to prevent someone from
accidentally mutating the original list.
●build_shift_dict(self, shift)
●Note: you may find the string module’s ascii_lowercase constant helpful here.
●apply_shift(self, shift)
○Hint: use build_shift_dict(self, shift). Remember that spaces and punctuation
should not be changed by the cipher.
pythonhomeworkhelp.com
Part 2: PlaintextMessage
Fill in the methods of the PlaintextMessage class found in ps4b.py
according to the specifications in the docstrings.
The methods you should fill in are:
●__init__(self, text, shift)
○Use the parent class constructor to make your code more concise. Take a look
at Style Guide #7 if you are confused.
●The getter methods
○get_shift(self)
○get_encryption_dict(self)
■Note: this should return a COPY of self.encryption_dict to prevent someone
from mutating the original dictionary.
○get_message_text_encrypted(self)
●change_shift(self, shift)
○Hint: think about what other methods you can use to make this easier. It
shouldn’t take more than a couple lines of code
pythonhomeworkhelp.com
Part 3: CiphertextMessage
Don’t you want to know what your friends are saying? Given an encrypted message,
if you know the shift used to encode the message, decoding it is trivial. If message is
the encrypted message, and s is the shift used to encrypt the message, then
apply_shift(message, 26-s) gives you the original plaintext message. Do you see
why?
The problem, of course, is that you don’t know the shift. But our encryption 5
method only has 26 distinct possible values for the shift! We know English is the
main language of these emails, so if we can write a program that tries each shift and
maximizes the number of English words in the decoded message, we can decrypt
their cipher!
The methods you should fill in are:
●__init__(self, text)
○Hint: use the parent class constructor to make your code more concise. Take a
look at Style Guide #7 if you are confused.
Fill in the methods of the CiphertextMessage class found in
ps4b.py according to the specifications in the docstrings.
pythonhomeworkhelp.com
●decrypt_message(self)
○Hint: you may find the helper function is_word(wordlist, word) and the string
method split useful ( https://docs.python.org/3/library/stdtypes.html#str.split
, or alternatively help(str.split) in your console)
○Note: is_word will ignore punctuation and other special characters when
considering whether a word is valid.
Part 4: Testing
Hint: The skeleton code contains a helper function get_story_string that returns the
encrypted version of the story as a string. Create a C iphertextMessage object using
the story string and use decrypt_message to return the appropriate shift value and
unencrypted story.
Write two test cases for PlaintextMessage and two test cases for
CiphertextMessage in comments under if __name__ == ‘__main__’ . Each test
case should display the input, expected output, and actual output. An example
can be found in ps4b.py . Then, decode the file story.txt and write the best shift
value used to decrypt the story, and unencrypted story in a comment
underneath your test cases.
pythonhomeworkhelp.com
Part C: Substitution Cipher
A better way to hide your messages is to use a substitution cipher. In this approach,
you create a hidden coding scheme, in which you substitute a randomly selected
letter for each original letter. For the letter “a”, you could pick any of the other 26
letters (including keeping “a”), for the letter “b”, you could then pick any of the
remaining 25 letters (other than what you selected for “a”) and so on. You can
probably see that the number of possibilities to test if you wanted to decrypt a
substitution ciphered message is much larger than for a Caesar cipher (26! compared
to 26). So for this problem, we are going to just consider substitution ciphers in
which the vowels are encrypted, with lowercase and uppercase versions of a letter
being mapped to corresponding letters. (For example, ‘A’ -> ‘O’ then ‘a’->’o’).
Classes and Inheritance
Similar to the Caesar cipher, we are going to use classes to explore this idea. We
will have a SubMessage class with general functions for handling Substitution
Messages of this kind. We will also write a class with a more specific
implementation and specification, EncryptedSubMessage, that inherits from the
SubMessage class.
pythonhomeworkhelp.com
Your job will be to fill methods for both classes according to the specifications
given in the docstrings of ps4c.py . Please remember that you never want to
directly access attributes outside a class - that’s why you have getter and setter
methods. Again, don’t overthink this; a get method should just return a variable
and a set method should just set an attribute equal to the parameter passed in.
Although they are simple, we need these methods in order to make sure that we
are not manipulating attributes we shouldn’t be. Directly using class attributes
outside of the class itself instead of using getters and setters will result in a point
deduction – and more importantly can cause you headaches as you design and
implement object class hierarchies.
Part 1: SubMessage
Fill in the methods of the SubMessage class found in
ps4c.py according to the specifications in the docstrings.
We have provided skeleton code for the following methods in the SubMessage class
- your task is to implement them. Please see the docstring comment with each
function for more information about the function specification.
pythonhomeworkhelp.com
●__init__(self, text)
●The getter methods
○get_message_text(self)
○get_valid_words(self)
■Note: this should return a COPY of self.valid_words to prevent
someone from mutating the original list.
●build_transpose_dict(self, vowels_permutation)
●apply_transpose(self, transpose_dict)
●Note: Pay close attention to the input specification when testing.
Part 2: EncryptedSubMessage
Fill in the methods of the EncryptedSubMessage class found in
ps4c.py according to the specifications in the docstrings.
Don’t you want to know what your friends are saying? Given an encrypted
message, if you know the substitution used to encode the message, decoding it is
trivial. You could just replace each letter with the correct, decoded letter.
The problem, of course, is that you don’t know the substitution. Even if we keep all
the consonants the same, we still have a lot of options for trying different
pythonhomeworkhelp.com
substitutions for the vowels. As with the Caesar cipher, we can use the trick of
testing (giving a proposed substitution) to see if the decoded words are real English
words. We then keep the decryption that yields the most valid English words. Note
that we have provided constants containing the values of the uppercase vowels,
lowercase vowels, uppercase consonants, and lowercase consonants, for your
convenience.
In this part, you can use your get_permutations method from part A (it is already
imported for you in the beginning of ps4c.py).
The methods you should fill in are:
●__init__(self, text)
○Hint: use the parent class constructor to make your code
more concise. Take a look at Style Guide #7 if you are confused.
●decrypt_message(self)
Part 3: Testing
pythonhomeworkhelp.com
Write two test cases for SubMessage and two test cases for 8
EncryptedSubMessage in comments under if __name__ ==
‘__main__’ . Each test case should contain the input, expected
output, function call used, and actual output.
pythonhomeworkhelp.com

More Related Content

What's hot

DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellBryan O'Sullivan
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Threeamiable_indian
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBryan O'Sullivan
 
The Expression Problem - Part 2
The Expression Problem - Part 2The Expression Problem - Part 2
The Expression Problem - Part 2Philip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2Philip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Philip Schwarz
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Philip Schwarz
 
Pattern matching programs
Pattern matching programsPattern matching programs
Pattern matching programsakruthi k
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldPhilip Schwarz
 
The Expression Problem - Part 1
The Expression Problem - Part 1The Expression Problem - Part 1
The Expression Problem - Part 1Philip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5Philip Schwarz
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Philip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...Philip Schwarz
 
From Scala Monadic Effects to Unison Algebraic Effects
From Scala Monadic Effects to Unison Algebraic EffectsFrom Scala Monadic Effects to Unison Algebraic Effects
From Scala Monadic Effects to Unison Algebraic EffectsPhilip Schwarz
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Philip Schwarz
 

What's hot (20)

DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore Haskell
 
The Expression Problem - Part 2
The Expression Problem - Part 2The Expression Problem - Part 2
The Expression Problem - Part 2
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 2
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
 
Applicative Functor
Applicative FunctorApplicative Functor
Applicative Functor
 
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
Game of Life - Polyglot FP - Haskell - Scala - Unison - Part 3
 
Pattern matching programs
Pattern matching programsPattern matching programs
Pattern matching programs
 
The Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and FoldThe Functional Programming Triad of Map, Filter and Fold
The Functional Programming Triad of Map, Filter and Fold
 
Pointers In C
Pointers In CPointers In C
Pointers In C
 
The Expression Problem - Part 1
The Expression Problem - Part 1The Expression Problem - Part 1
The Expression Problem - Part 1
 
Pointer in c
Pointer in c Pointer in c
Pointer in c
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 5
 
E6
E6E6
E6
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala Part 2 ...
 
From Scala Monadic Effects to Unison Algebraic Effects
From Scala Monadic Effects to Unison Algebraic EffectsFrom Scala Monadic Effects to Unison Algebraic Effects
From Scala Monadic Effects to Unison Algebraic Effects
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
 

Similar to Best Python Assignment Help

Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaghu nath
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxhardii0991
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regexYongqiang Li
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings MethodsMr Examples
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second sessionAhmad Bashar Eter
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotesSowri Rajan
 
Encryption is a process of converting a message, image, or any other .pdf
 Encryption is a process of converting a message, image, or any other .pdf Encryption is a process of converting a message, image, or any other .pdf
Encryption is a process of converting a message, image, or any other .pdfrachanaprade
 
Acm aleppo cpc training ninth session
Acm aleppo cpc training ninth sessionAcm aleppo cpc training ninth session
Acm aleppo cpc training ninth sessionAhmad Bashar Eter
 
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docx
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docxCOMPLEX AND USER DEFINED TYPESPlease note that the material on t.docx
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docxdonnajames55
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2ndConnex
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Pythonshailaja30
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
 

Similar to Best Python Assignment Help (20)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
LectureNotes-04-DSA
LectureNotes-04-DSALectureNotes-04-DSA
LectureNotes-04-DSA
 
Objective c slide I
Objective c slide IObjective c slide I
Objective c slide I
 
Php
PhpPhp
Php
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regex
 
Python Strings Methods
Python Strings MethodsPython Strings Methods
Python Strings Methods
 
Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3Anton Kasyanov, Introduction to Python, Lecture3
Anton Kasyanov, Introduction to Python, Lecture3
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second session
 
Unitii classnotes
Unitii classnotesUnitii classnotes
Unitii classnotes
 
05 c++-strings
05 c++-strings05 c++-strings
05 c++-strings
 
Encryption is a process of converting a message, image, or any other .pdf
 Encryption is a process of converting a message, image, or any other .pdf Encryption is a process of converting a message, image, or any other .pdf
Encryption is a process of converting a message, image, or any other .pdf
 
Acm aleppo cpc training ninth session
Acm aleppo cpc training ninth sessionAcm aleppo cpc training ninth session
Acm aleppo cpc training ninth session
 
Get Fast C++ Homework Help
Get Fast C++ Homework HelpGet Fast C++ Homework Help
Get Fast C++ Homework Help
 
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docx
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docxCOMPLEX AND USER DEFINED TYPESPlease note that the material on t.docx
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docx
 
C –FAQ:
C –FAQ:C –FAQ:
C –FAQ:
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
Introduction To Python
Introduction To  PythonIntroduction To  Python
Introduction To Python
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
 

More from Python Homework Help

Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Homework Help
 

More from Python Homework Help (20)

Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python HomeworkComplete my Python Homework
Complete my Python Homework
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptxIntroduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
 
Basic Python Programming.pptx
Basic Python Programming.pptxBasic Python Programming.pptx
Basic Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptxPython Programming Homework Help.pptx
Python Programming Homework Help.pptx
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework HelpPerfect Python Homework Help
Perfect Python Homework Help
 

Recently uploaded

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

Best Python Assignment Help

  • 1. For any Assignment related queries, Call us at : - +1 678 648 4277 You can mail us at :- support@pythonhomeworkhelp.com or reach us at :- https://www.pythonhomeworkhelp.com/
  • 2. Part A: Permutations of a string A permutation is simply a name for a reordering. So the permutations of the string ‘abc’ are ‘abc’, ‘acb’, ‘bac’, ‘bca’, ‘cab’, and ‘cba’. Note that a sequence is a permutation of itself (the trivial permutation). For this part of the pset you’ll need to write a recursive function get_permutations that takes a string and returns a list of all its permutations. You will find this function helpful later in the pset for part C. A couple of notes on the requirements: Recursion MUST be used , global variables may NOT be used. Additionally, it is okay to use loops to code the solution. The order of the returned permutations does not matter. Please also avoid returning duplicates in your final list. Suggested Approach In order to solve any recursive problem, we must have at least one base case and a recursive case (or cases). We can think of our base case as the simplest input we could have to this problem (for which determining the solution is trivial and requires no recursion) -- for this approach, our base case is if sequence is a single character (there’s only one way to order a single character). pythonhomeworkhelp.com
  • 3. If sequence is longer than one character, we need to identify a simpler version of the problem that, if solved, will help us easily find all permutations for sequence . The pseudocode below gives one approach to recursively solving this problem. Given an input string sequence : ●Base case: ○if sequence is a single character, there’s only one way to order it ■return a singleton list containing sequence ●Recursive case: ○suppose we have a method that can give us a list of all permutations of all but the first character in sequence (Hint: think recursion) ○then the permutations of all characters in sequence would be all the different ways we can insert the first character into each permutation of the remaining characters ■example: if our word was ‘bust’, we hold out the character ‘b’ and get the list [‘ust’, ‘sut’, ‘stu’, ‘uts’, ‘tus’, ‘tsu’] ●then ‘ust’ gives us: ‘b ust’, ‘ub st’, ‘us b t’, ‘ust b ’ ●‘sut’ gives us: ‘b sut’, ‘s b ut’, ‘su b t’, ‘sut b ’ ●and so on … pythonhomeworkhelp.com
  • 4. Implement the get_permutations(sequence) function found in ps4a.py according to the specifications in the docstring. Write three test cases for your function in comments under if __name__ == ‘__main__’ . Each test case should display the input, expected output, and actual output. See the if __name__ == ‘__main__’ for an example. Part B: Cipher Like Caesar Ever want to relive the glory days of your youth and pass secret messages to your friends? Well, here is your chance! But first, here is some vocabulary: ●Encryption - the process of obscuring or encoding messages to make them unreadable ●Decryption - making encrypted messages readable again by decoding them ●Cipher - algorithm for performing encryption and decryption ●Plaintext - the original message ●Ciphertext - the encrypted message. Note: a ciphertext still contains all of the original message information, even if it looks like gibberish. pythonhomeworkhelp.com
  • 5. Caesar Cipher The idea of the Caesar Cipher is to pick an integer and shift every letter of your message by that integer. In other words, suppose the shift is kth . Then, all instances of the i letter of the alphabet that appear in the plaintext should become the (i + k) th letter of the alphabet in the ciphertext. You will need to be careful with the case in which i + k > 26 (the length of the alphabet). We will treat uppercase and lowercase letters individually, so that uppercase letters are always mapped to an uppercase letter, and lowercase letters are always mapped to a lowercase letter. If an uppercase letter maps to “A”, then the same lowercase letter should map to “a”. Punctuation and spaces should be retained and not changed. For example, a plaintext message with a comma should have a corresponding ciphertext with a comma in the same position. Examples: Plain text sift ciphertext ‘abcdef’ ‘Hello, World!’ ‘’ 2 4 any value ‘cdefgh’ ‘Lipps, Asvph!’ ‘’ pythonhomeworkhelp.com
  • 6. Classes and Inheritance This is your first experience coding with classes! Get excited! We will have a Message class with two subclasses PlaintextMessage and CiphertextMessage . Message contains methods that could be used to apply a cipher to a string, either to 3 encrypt or to decrypt a message (since for Caesar codes this is the same action). PlaintextMessage has methods to encode a string using a specified shift value; our class will always create an encoded version of the message, and will have methods for changing the encoding. CiphertextMessage contains a method used to decode a string. When you have completed your implementation, you can either create a CiphertextMessage instance using an encrypted string that someone provides you and try to decrypt it; or you can encrypt your own PlaintextMessage instance, then create a CiphertextMessage instance from the encrypted message within the PlaintextMessage instance, and try to decrypt it and see if it matches the original plaintext message. Your job will be to fill methods for all three of these classes according to the specifications given in the docstrings of ps4b.py . Please remember that you never want to directly access attributes outside a class - that’s why you have getter and setter methods. pythonhomeworkhelp.com
  • 7. Don’t overthink this; a getter method should just return an attribute and a set method should just set an attribute equal to the argument passed in. Although they seem simple, we need these methods in order to make sure that we are not manipulating attributes we shouldn’t be. Directly using class attributes outside of the class itself instead of using getters and setters will result in a point deduction – and more importantly can cause you headaches as you design and implement object class hierarchies. Rules You do not have to use recursion in Part B, but you are welcome to. There are a couple of helper functions that we have implemented for you: load_words and is_word . You may use these in your solution and you do not need to understand them completely, but should read the associated comments. You should read and understand the helper code in the rest of the file and use it to guide your solution. Part 1: Message Fill in the methods of the Message class found in ps4b.py according to the specifications in the docstrings. pythonhomeworkhelp.com
  • 8. We have provided skeleton code in the Message class for the following functions - your task is to implement them. Please see the docstring comment with each function for more information about the function specification. ●__init__(self, text) ●The getter methods 4 ○get_message_text(self) ●Note: This should return an immutable version of the message text we added to this object in init. Luckily, strings are already immutable objects, so we can simply return that string. ○get_valid_words(self) ●Note: this should return a COPY of self.valid_words to prevent someone from accidentally mutating the original list. ●build_shift_dict(self, shift) ●Note: you may find the string module’s ascii_lowercase constant helpful here. ●apply_shift(self, shift) ○Hint: use build_shift_dict(self, shift). Remember that spaces and punctuation should not be changed by the cipher. pythonhomeworkhelp.com
  • 9. Part 2: PlaintextMessage Fill in the methods of the PlaintextMessage class found in ps4b.py according to the specifications in the docstrings. The methods you should fill in are: ●__init__(self, text, shift) ○Use the parent class constructor to make your code more concise. Take a look at Style Guide #7 if you are confused. ●The getter methods ○get_shift(self) ○get_encryption_dict(self) ■Note: this should return a COPY of self.encryption_dict to prevent someone from mutating the original dictionary. ○get_message_text_encrypted(self) ●change_shift(self, shift) ○Hint: think about what other methods you can use to make this easier. It shouldn’t take more than a couple lines of code pythonhomeworkhelp.com
  • 10. Part 3: CiphertextMessage Don’t you want to know what your friends are saying? Given an encrypted message, if you know the shift used to encode the message, decoding it is trivial. If message is the encrypted message, and s is the shift used to encrypt the message, then apply_shift(message, 26-s) gives you the original plaintext message. Do you see why? The problem, of course, is that you don’t know the shift. But our encryption 5 method only has 26 distinct possible values for the shift! We know English is the main language of these emails, so if we can write a program that tries each shift and maximizes the number of English words in the decoded message, we can decrypt their cipher! The methods you should fill in are: ●__init__(self, text) ○Hint: use the parent class constructor to make your code more concise. Take a look at Style Guide #7 if you are confused. Fill in the methods of the CiphertextMessage class found in ps4b.py according to the specifications in the docstrings. pythonhomeworkhelp.com
  • 11. ●decrypt_message(self) ○Hint: you may find the helper function is_word(wordlist, word) and the string method split useful ( https://docs.python.org/3/library/stdtypes.html#str.split , or alternatively help(str.split) in your console) ○Note: is_word will ignore punctuation and other special characters when considering whether a word is valid. Part 4: Testing Hint: The skeleton code contains a helper function get_story_string that returns the encrypted version of the story as a string. Create a C iphertextMessage object using the story string and use decrypt_message to return the appropriate shift value and unencrypted story. Write two test cases for PlaintextMessage and two test cases for CiphertextMessage in comments under if __name__ == ‘__main__’ . Each test case should display the input, expected output, and actual output. An example can be found in ps4b.py . Then, decode the file story.txt and write the best shift value used to decrypt the story, and unencrypted story in a comment underneath your test cases. pythonhomeworkhelp.com
  • 12. Part C: Substitution Cipher A better way to hide your messages is to use a substitution cipher. In this approach, you create a hidden coding scheme, in which you substitute a randomly selected letter for each original letter. For the letter “a”, you could pick any of the other 26 letters (including keeping “a”), for the letter “b”, you could then pick any of the remaining 25 letters (other than what you selected for “a”) and so on. You can probably see that the number of possibilities to test if you wanted to decrypt a substitution ciphered message is much larger than for a Caesar cipher (26! compared to 26). So for this problem, we are going to just consider substitution ciphers in which the vowels are encrypted, with lowercase and uppercase versions of a letter being mapped to corresponding letters. (For example, ‘A’ -> ‘O’ then ‘a’->’o’). Classes and Inheritance Similar to the Caesar cipher, we are going to use classes to explore this idea. We will have a SubMessage class with general functions for handling Substitution Messages of this kind. We will also write a class with a more specific implementation and specification, EncryptedSubMessage, that inherits from the SubMessage class. pythonhomeworkhelp.com
  • 13. Your job will be to fill methods for both classes according to the specifications given in the docstrings of ps4c.py . Please remember that you never want to directly access attributes outside a class - that’s why you have getter and setter methods. Again, don’t overthink this; a get method should just return a variable and a set method should just set an attribute equal to the parameter passed in. Although they are simple, we need these methods in order to make sure that we are not manipulating attributes we shouldn’t be. Directly using class attributes outside of the class itself instead of using getters and setters will result in a point deduction – and more importantly can cause you headaches as you design and implement object class hierarchies. Part 1: SubMessage Fill in the methods of the SubMessage class found in ps4c.py according to the specifications in the docstrings. We have provided skeleton code for the following methods in the SubMessage class - your task is to implement them. Please see the docstring comment with each function for more information about the function specification. pythonhomeworkhelp.com
  • 14. ●__init__(self, text) ●The getter methods ○get_message_text(self) ○get_valid_words(self) ■Note: this should return a COPY of self.valid_words to prevent someone from mutating the original list. ●build_transpose_dict(self, vowels_permutation) ●apply_transpose(self, transpose_dict) ●Note: Pay close attention to the input specification when testing. Part 2: EncryptedSubMessage Fill in the methods of the EncryptedSubMessage class found in ps4c.py according to the specifications in the docstrings. Don’t you want to know what your friends are saying? Given an encrypted message, if you know the substitution used to encode the message, decoding it is trivial. You could just replace each letter with the correct, decoded letter. The problem, of course, is that you don’t know the substitution. Even if we keep all the consonants the same, we still have a lot of options for trying different pythonhomeworkhelp.com
  • 15. substitutions for the vowels. As with the Caesar cipher, we can use the trick of testing (giving a proposed substitution) to see if the decoded words are real English words. We then keep the decryption that yields the most valid English words. Note that we have provided constants containing the values of the uppercase vowels, lowercase vowels, uppercase consonants, and lowercase consonants, for your convenience. In this part, you can use your get_permutations method from part A (it is already imported for you in the beginning of ps4c.py). The methods you should fill in are: ●__init__(self, text) ○Hint: use the parent class constructor to make your code more concise. Take a look at Style Guide #7 if you are confused. ●decrypt_message(self) Part 3: Testing pythonhomeworkhelp.com
  • 16. Write two test cases for SubMessage and two test cases for 8 EncryptedSubMessage in comments under if __name__ == ‘__main__’ . Each test case should contain the input, expected output, function call used, and actual output. pythonhomeworkhelp.com