Home / Expert Answers / Accounting / the-theme-of-this-activity-is-to-learn-the-use-of-complex-combinations-of-loops-dictionaries-and-pa831

(Solved): The theme of this activity is to learn the use of complex combinations of Loops, Dictionaries and ...



The theme of this activity is to learn the use of complex combinations of Loops, Dictionaries
and Functions in Python. The goStep 3-b: Now, add the encrypted symbol for the vowel in the dictionary created in step 2.
(Think of using appropriate key-va

The encrypted text is: h2114 w4rld
Part 3: Deciphering the encrypted text
Step 9: Start a loop for all variables in the dicti

The theme of this activity is to learn the use of complex combinations of Loops, Dictionaries and Functions in Python. The goal of this activity is to create a code that can decipher an encrypted text, given the encrypted text and a codebook with alternate symbols for characters (vowels). Point to note, all the inputs and outputs are case-sensitive. Be sure to create a header comment with the title of this program, your name, the current date, and a short summary about the purpose of the program (in your own words). Your program should be made of this following steps: Part 1: Entering and storing the encryption symbols Step 1: Create a variable replace_list, with a list of 5 vowels as characters, all lowercase. Step 2: Initialize an empty dictionary to hold the encrypted symbols. Step 3: Start a loop for all the values in replace_list. Step 3-a: Ask user for input, to use as an encrypted symbol for the current vowel in replace_list. It should look like: Encrypted symbol for a is: I We will use a simple case of encryption here. For example, the encryption could be: a ? 1, b?2, C3, 04, e ? 5. Step 3-b: Now, add the encrypted symbol for the vowel in the dictionary created in step 2. (Think of using appropriate key-value pairs!) Step 4: Print the whole dictionary here, to see the complete encryption symbols. This is your dictionary: {'a': '1', 'e': '2', 'i': '3', 'o': '4', 'u': '5'} Part 2: Reading the encrypted text Step 5: You should create a text file in the same location as your code, titled “examplefile.txt”. This file contains one line of encrypted text. For this example, we will use “h2|14 w4rld” (which is basically an encoded version of “hello world” using the code symbols decided in step 3-a). Step 6: Write a code snippet that opens the text file, reads the lines from there and stores them in a list. (It is a two-line code, standard for Python file-reading operations). Step 7: From the lines read, store only the first value as an input string in a new variable. (Using only the first value, since we have only one line in examplefile.txt. We do not need additional lines for this code.) Step 8: Print the encrypted text to show successful reading from the text file. The encrypted text is: h2114 w4rld Part 3: Deciphering the encrypted text Step 9: Start a loop for all variables in the dictionary. Step 9-a: Check if the corresponding value (character) from the dictionary is already present in the encrypted text (read in step 7). If it is, replace the encrypted character in the encrypted text with the original symbol (aka, replace “1” with "a"). This step should technically change all the encryption, as it is running in a loop for all variables in the dictionary. Step 10: Print the deciphered text. The resulting string is: hello world Overall note: This input process is case-sensitive, meaning, it does differentiate between lowercase letters, uppercase letters, and symbols. When prompted for an encrypted symbol, assume the user only enters one character. Example Test Case: Encrypted symbol for a is: 1 Encrypted symbol for e is: 2 Encrypted symbol for i is: 3 Encrypted symbol for o is: 4 Encrypted symbol for u is: 5 This is your dictionary: {'a': '1', 'e': '2', 'i': '3', 'o' '4', 'u': '5'}


We have an Answer from Expert

View Expert Answer

Expert Answer


replace_list=['a','e','i','o','u'] map_data={} for i in replace_list: map_data[i]=in
We have an Answer from Expert

Buy This Answer $5

Place Order