In Python please!

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In Python please!

# variables for task 2
{80: "P", 121: 'у', 116: 't', 104: "h', 111: 'о', 110: 'n', 105: 'i', 115: 's', 99: "с', 108: '1,
', 44: ',', 45: '-', 95: '_', 40: '(', 42: '*', 41: ')', 47: '/', 92: '\\', 61: '=', 39:
58: ':', 59: ';'}
decoder
46: '.', 32:
124: '|', 96:
...
[[80, 121, 116, 104, 111, 110], [105, 115], [99, 111, 111, 108, 46]]
[[32, 32, 32, 44, 45, 46], [32, 95, 40, 42, 95, 42, 41, 95], [40, 95, 32, 32, 111, 32, 32, 95, 41],
msg1
msg2
[32, 32, 47, 32, 111, 32, 92], [32, 40, 95, 47, 32, 92, 95, 41, 32]]
msg3
32, 32, 32, 95, 95, 46, 46, 45, 45, 45, 46, 46, 95, 95], [32, 44, 45, 61, 39, 32, 32, 47, 32, 32, 124, 32,
32, 92, 32, 32, 96, 61, 45, 46], [58, 45, 45, 46, 46, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 46, 46, 45,
45, 59], [32, 92, 46, 44, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 44, 46, 47]]
[[32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40], [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 41], [32, 32,
%3D
Transcribed Image Text:# variables for task 2 {80: "P", 121: 'у', 116: 't', 104: "h', 111: 'о', 110: 'n', 105: 'i', 115: 's', 99: "с', 108: '1, ', 44: ',', 45: '-', 95: '_', 40: '(', 42: '*', 41: ')', 47: '/', 92: '\\', 61: '=', 39: 58: ':', 59: ';'} decoder 46: '.', 32: 124: '|', 96: ... [[80, 121, 116, 104, 111, 110], [105, 115], [99, 111, 111, 108, 46]] [[32, 32, 32, 44, 45, 46], [32, 95, 40, 42, 95, 42, 41, 95], [40, 95, 32, 32, 111, 32, 32, 95, 41], msg1 msg2 [32, 32, 47, 32, 111, 32, 92], [32, 40, 95, 47, 32, 92, 95, 41, 32]] msg3 32, 32, 32, 95, 95, 46, 46, 45, 45, 45, 46, 46, 95, 95], [32, 44, 45, 61, 39, 32, 32, 47, 32, 32, 124, 32, 32, 92, 32, 32, 96, 61, 45, 46], [58, 45, 45, 46, 46, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 46, 46, 45, 45, 59], [32, 92, 46, 44, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 44, 46, 47]] [[32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40], [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 41], [32, 32, %3D
For task2, you'll use four variables in the starting code: decoder, msg1, msg2, msg3.
The decoder dictionary consists of integer keys that represent codes. The value of each key is a single character string.
The message strings (msg1, msg2, msg3) are lists of lists. Each inner list is a sequence of integers (code) that represents a
character in a string. Use the decoder dictionary to look up the correct character to convert the list to a string.
See diagram below:
The decoder variable is a dictionary where the key in an integer
(code) and the associated value is a string with a single character.
decoder = { code: 'Y', code:'Z', code: 'X' }
The msg1 variable(s) [there are three in your lab, msg1, msg2, msg3] are lists of lists.
Each inner list is a set of code numbers that represent a single
character in a string.
msg1 = [ [code, code, code, ., code],
..
[code, code, code .., code] ]
Convert the lists of codes to a string
[code, code, ., code)
Final string
decoder
Use the dictionary to
decode the codes into
their associated characters.
"String1"
"StringN"
[code, code, ., code]
Example
decoder = { 8e: 'H', 14: 'o', 101: 'e', 93:'1'}
code list
[8е, 101, 93, 93, 14]
final string
decoded by dictionary
'H', 'e', 'l', 'l', 'o'
->
->
"Hello"
Task 2 is to decode all three messages and print them out. In the following, I show the results of decoding messages: msg1, msg2.
I'm not showing msg3, so you can find out what it is on your own. Your output needs to have all three strings.
You have complete freedom to implement this task in anyway you want as long as the output is correct. You may introduce your
own functions. Before printing each message, print the message ID (i.e., 1, 2, or 3) above it as shown below:
Task 2
Example for msg1
--- Message 1
Python
msg1 = [[80, 121, 116, 104, 111, 110],
[105, 115], [99, 111, 111, 108, 46]]
is
cool.
msg1 variable is a list of 3 lists.
Message 2
Each list is decoded with the help of the decoder
dictionary to produce three strings as described
above.
_(*_*)_
Print each string on its own line to get the final
decoded message.
(/ L)
Transcribed Image Text:For task2, you'll use four variables in the starting code: decoder, msg1, msg2, msg3. The decoder dictionary consists of integer keys that represent codes. The value of each key is a single character string. The message strings (msg1, msg2, msg3) are lists of lists. Each inner list is a sequence of integers (code) that represents a character in a string. Use the decoder dictionary to look up the correct character to convert the list to a string. See diagram below: The decoder variable is a dictionary where the key in an integer (code) and the associated value is a string with a single character. decoder = { code: 'Y', code:'Z', code: 'X' } The msg1 variable(s) [there are three in your lab, msg1, msg2, msg3] are lists of lists. Each inner list is a set of code numbers that represent a single character in a string. msg1 = [ [code, code, code, ., code], .. [code, code, code .., code] ] Convert the lists of codes to a string [code, code, ., code) Final string decoder Use the dictionary to decode the codes into their associated characters. "String1" "StringN" [code, code, ., code] Example decoder = { 8e: 'H', 14: 'o', 101: 'e', 93:'1'} code list [8е, 101, 93, 93, 14] final string decoded by dictionary 'H', 'e', 'l', 'l', 'o' -> -> "Hello" Task 2 is to decode all three messages and print them out. In the following, I show the results of decoding messages: msg1, msg2. I'm not showing msg3, so you can find out what it is on your own. Your output needs to have all three strings. You have complete freedom to implement this task in anyway you want as long as the output is correct. You may introduce your own functions. Before printing each message, print the message ID (i.e., 1, 2, or 3) above it as shown below: Task 2 Example for msg1 --- Message 1 Python msg1 = [[80, 121, 116, 104, 111, 110], [105, 115], [99, 111, 111, 108, 46]] is cool. msg1 variable is a list of 3 lists. Message 2 Each list is decoded with the help of the decoder dictionary to produce three strings as described above. _(*_*)_ Print each string on its own line to get the final decoded message. (/ L)
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY