Question: *Python 3 Question* In a computer network, data must be transmitted between different nodes (devices). Unfortunately, this is not an error-proof process. Transmission problems can
*Python 3 Question*
In a computer network, data must be transmitted between different nodes (devices). Unfortunately, this is not an error-proof process. Transmission problems can garble a message, leading to errors in the data that is received. Luckily, the errors are (usually) randomly distributed, so they will occur in different places each time a message is transmitted. By transmitting the same message multiple times and monitoring the results, we can gather data that will help us to reconstruct the original message. To do this, we examine each position of each message copy. The value that occurs most frequently in a specific position is (usually) the correct value for that position.
For example, consider the following repeated/retransmitted message (in this example, spaces have been inserted between each letter for clarity):

In the first column/position, we have 1 f, 1 g, and 6 h's. Since 'h' is the most common value for the first letter, we can guess that the first letter of the original message was most likely 'h'. The second position has 5 e's, 1 h, 1 p, and 1 t, so 'e' is the most likely second character. Repeat this process for each position in the message copies. In this case, the original message turns out to be "helloworld". For this lab, you will construct a program that reads in a series of (garbled) strings from the user and uses frequency analysis to determine what the original message was.
1. Start by defining a Python function named getMessages(). This function uses a while loop to read a series of strings from the user, until the user enters the string "DONE" to stop. As you read each string, add it to the end of a list. You may assume that each input string has the same number of characters, and only contains lowercase letters (i.e., there will not be any spaces, digits, symbols, or capital letters). When the user has finished entering input strings, this function should return the list of strings entered by the user.
2. Second, define a function named countFrequencies(). This function takes two arguments: a list of strings and an integer representing an index value. For each string in the list, the function counts the number of times each character occurs at the specified index (for example, if the index is 4, the function will look at the fifth character of each string). You may assume that the index value always falls into the range 0(string length- 1), inclusive.
Create a dictionary where each key is a lowercase letter; the value of each key is the number of strings that have that letter in the specified position (for example, if the index value is 2, key 'b' will record the number of strings that have 'b' in index 2). After examining every string in the list, return the dictionary of letter frequencies that was just generated.
3. Third, define a function named mostCommonLetter(). This function takes a dictionary as its sole argument. It returns the key that maps to the largest value. For example, given the dictionary {'a':3, 'b':5, 'c':4}, this function would return 'b'. If two (or more) keys are tied for the highest value, you may return any one of those keys as the function result.
4. Finally, write some Python code that combines the functions you defined in the preceding steps to reconstruct a garbled (multiply-transmitted) message like the example above.

Here is the required starter that needs to be used for creating this program:
# garble.py -- generate multiple garbled versions of a message
import random
alpha = "abcdefghijklmnopqrstuvwxyz"
original = input("Enter the original message: ")
garble_rate = -1
while garble_rate 9: garble_rate = int(input("Enter the garbling rate as an integer between 0 and 9: "))
print() print ("Garbled messages: ")
for i in range(garble_rate + (garble_rate // 2) + 1): # increase the number of transmissions as the garbling rate increases garbled = ""
for ch in original: garb = random.randint(0,10)
if garb
print(garbled)
print()
hejwo a p r o d gelq hwkb p y (2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
