The decoder dictionary consists of integer keys that represent codes. The value of each key is a single character string.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

# variables for task 2
decoder = {80: 'P', 121: 'y', 116: 't', 104: 'h', 111: 'o', 110: 'n', 105: 'i', 115: 's', 99: 'c', 108: 'l', 46: '.', 32: ' ', 44: ',', 45: '-', 95: '_', 40: '(', 42: '*', 41: ')', 47: '/', 92: '\\', 61: '=', 39: "'", 124: '|', 96: '`', 58: ':', 59: ';'}
msg1 = [[80, 121, 116, 104, 111, 110], [105, 115], [99, 111, 111, 108, 46]]
msg2 = [[32, 32, 32, 44, 45, 46], [32, 95, 40, 42, 95, 42, 41, 95], [40, 95, 32, 32, 111, 32, 32, 95, 41], [32, 32, 47, 32, 111, 32, 92], [32, 40, 95, 47, 32, 92, 95, 41, 32]]
msg3 = [[32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40], [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 41], [32, 32, 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]]

Message decodin
Iists, using dictionarles)
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.
msgi - ( [code, code, code, .., code], .. ., [code, code, code .., code] 1
Convert the lists of codes to a string
(code, code, ., code)
decoder
Final string
Use the dictionary to
"String1"
"StringN"
(code, code, ., code]
decode the codes into
their associated characters.
Example
decoder - { 80: 'H", 14:'0', 1e1: 'e', 93:'1'}
decoded by dictionary
'H', 'e', '1', 'l', 'o'
final string
"Hello"
code list
[ве, 1е1, 93, 9з, 14]
->
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
.-----
Message 1
Python
is
cool.
Example for msg1
msg1 = [[80, 121, 116, 104, 111, 110],
[105, 115], [99, 111, 111, 108, 46]]
---
----
msg1 variable is a list of 3 lists.
Each list is decoded with the help of the decoder
Message 2
---
----
dictionary to produce three strings as described
above.
(C o )
Print each string on its own line to get the final
decoded message.
Transcribed Image Text:Message decodin Iists, using dictionarles) 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. msgi - ( [code, code, code, .., code], .. ., [code, code, code .., code] 1 Convert the lists of codes to a string (code, code, ., code) decoder Final string Use the dictionary to "String1" "StringN" (code, code, ., code] decode the codes into their associated characters. Example decoder - { 80: 'H", 14:'0', 1e1: 'e', 93:'1'} decoded by dictionary 'H', 'e', '1', 'l', 'o' final string "Hello" code list [ве, 1е1, 93, 9з, 14] -> 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 .----- Message 1 Python is cool. Example for msg1 msg1 = [[80, 121, 116, 104, 111, 110], [105, 115], [99, 111, 111, 108, 46]] --- ---- msg1 variable is a list of 3 lists. Each list is decoded with the help of the decoder Message 2 --- ---- dictionary to produce three strings as described above. (C o ) Print each string on its own line to get the final decoded message.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Fundamentals of Input and Output Performance
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education