CrackingCodes.Ch19 package¶
Submodules¶
CrackingCodes.Ch19.PracticeQuestions module¶
Chapter 19 Practice Questions
Answers Chapter 19 Practice Questions via Python code.
CrackingCodes.Ch19.freqAnalysis module¶
Frequency Finder
Analyzes frequency of letters in given message compared to the most common occurring letters to determine if message is in the English language.
-
CrackingCodes.Ch19.freqAnalysis.
ETAOIN
¶ String containing uppercase latin letters in order from most to least common.
Type: str
-
CrackingCodes.Ch19.freqAnalysis.
LETTERS
¶ String containing uppercase latin letters in alphabetical order.
Type: str
Note
- Compares six most and six least common letters in the English language.
- https://www.nostarch.com/crackingcodes/ (BSD Licensed)
-
CrackingCodes.Ch19.freqAnalysis.
englishFreqMatchScore
(message: str) → int[source]¶ English Frequency Match Score
Calculates number of matches that the string in the message parameter has when its letter frequency is compared to English letter frequency.
Parameters: message – String containing message to calculate English match score. Returns: Number representing message’s matches to English letter frequency. Note
- A “match” is how many of its six most frequent and six least frequent letters are among the six most frequent and six least frequent letters for English.
- A “perfect score” is 12
-
CrackingCodes.Ch19.freqAnalysis.
getFrequencyOrder
(message: str) → str[source]¶ Get frequency order
Analyzes frequency of each letter in given message and returns string with each letter from most to least frequent.
Parameters: message – String containing message to analyze frequency. Returns: String of the alphabet letters arranged in order of most frequently occurring in the message parameter.
-
CrackingCodes.Ch19.freqAnalysis.
getItemAtIndexZero
(items: tuple)[source]¶ Get element at index zero
Helper function that returns the first element of a given tuple.
Parameters: items – Tuple containing a latin letter and its frequency count. Returns: the latin letter. Return type: The first element of the given tuple
-
CrackingCodes.Ch19.freqAnalysis.
getLetterCount
(message: str) → dict[source]¶ Get letter count
Counts the frequency of all latin letters in a given message.
Parameters: message – String containing message to analyze letter frequency. Returns: Dictionary with keys of single letters and values of the count of how many times they appear in the message parameter.