Question 3 - (this question MAY appear on the assignment quiz) Write a Python program to solve the following problem: Given a two-dimensional list/table containing hexadecimal colour codes representing a picture, write functions to look for the corresponding colour names in another two-dimensional colour lookup table (see below) and generate a resulting two-dimensional table containing the names of the colours in the appropriate locations, corresponding to where the colour code was in the original hexadecimal table. See sample expected output below. Call the file containing your program, colour_codes.py. Include the following functions in your code: • a function to find the appropriate row, in the colour lookup table, corresponding to the first three digits of the colour code in the picture; the function should take, as parameters, the lookup table and a string containing the first three digits of the colour code and return the code's row location (e.g., partial code "FFO" would give 4 as a return value since it can be found in row 4 of the lookup table) • a function to find the appropriate column, in the colour lookup table, corresponding to the last three digits of the colour code in the picture; the function should take, as parameters, the lookup table and a string containing the last three digits of the colour code and return the code's column location (e.g., partial code "FO0" would give 3 as a return value since it can be found in column 3 of the lookup table) • a function to print the resulting table in the format shown in the sample expected output below • a main function to use the other functions to get the resulting "colour name" table and print it; the main function should contain the two given two-dimensional lists/tables as given below (colourLookup and sare encodedPic)

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
Question 3 - (this question MAY appear on the assignment quiz)
Write a Python program to solve the following problem:
Given a two-dimensional list/table containing hexadecimal colour codes representing a picture, write
functions to look for the corresponding colour names in another two-dimensional colour lookup table (see
below) and generate a resulting two-dimensional table containing the names of the colours in the appropriate
locations, corresponding to where the colour code was in the original hexadecimal table. See sample
expected output below. Call the file containing your program, colour_codes.py.
Include the following functions in your code:
• a function to find the appropriate row, in the colour lookup table, corresponding to the first three digits of
the colour code in the picture; the function should take, as parameters, the lookup table and a string
containing the first three digits of the colour code and return the code's row location (e.g., partial code "FF0"
would give 4 as a return value since it can be found in row 4 of the lookup table)
• a function to find the appropriate column, in the colour lookup table, corresponding to the last three digits
of the colour code in the picture; the function should take, as parameters, the lookup table and a string
containing the last three digits of the colour code and return the code's column location (e.g., partial code
"FO0" would give 3 as a return value since it can be found in column 3 of the lookup table)
• a function to print the resulting table in the format shown in the sample expected output below
a main function to use the other functions to get the resulting "colour name" table and print it; the main
function should contain the two given two-dimensional lists/tables as given below (colourLookup and
encodedPic)
Transcribed Image Text:Question 3 - (this question MAY appear on the assignment quiz) Write a Python program to solve the following problem: Given a two-dimensional list/table containing hexadecimal colour codes representing a picture, write functions to look for the corresponding colour names in another two-dimensional colour lookup table (see below) and generate a resulting two-dimensional table containing the names of the colours in the appropriate locations, corresponding to where the colour code was in the original hexadecimal table. See sample expected output below. Call the file containing your program, colour_codes.py. Include the following functions in your code: • a function to find the appropriate row, in the colour lookup table, corresponding to the first three digits of the colour code in the picture; the function should take, as parameters, the lookup table and a string containing the first three digits of the colour code and return the code's row location (e.g., partial code "FF0" would give 4 as a return value since it can be found in row 4 of the lookup table) • a function to find the appropriate column, in the colour lookup table, corresponding to the last three digits of the colour code in the picture; the function should take, as parameters, the lookup table and a string containing the last three digits of the colour code and return the code's column location (e.g., partial code "FO0" would give 3 as a return value since it can be found in column 3 of the lookup table) • a function to print the resulting table in the format shown in the sample expected output below a main function to use the other functions to get the resulting "colour name" table and print it; the main function should contain the two given two-dimensional lists/tables as given below (colourLookup and encodedPic)
Colour Lookup Table:
000
FOO
FFF
BLUE15
000
BLACK
BLACK15
FFF
YELLOW15 WHITE
YELLOW
0OF
GREEN15
CYAN
GREEN
FFO
RED
MAGENTA15
RED15
Given encoded picture:
000000
000000
000000
FF0000
000000
000000
000000
000000 000000
FF0000
000000
FFO000
000000
000000
000000
FFO000
000000
FFFFFF
000000 FF0000
000000
000000
000000
FF0000
000000
FFO000
000000
000000
000000
000000 000000
FF0000
000000
000000 00000
000000
000000 000000
OOFF00
000000
000000
000000
000000
000000
000000 00FF00
OOFF00
0OFF00
000000
000000
000000
000000
OOFF00
000000
000000
000000
Sample expected output:
BLACK
BLACK
BLACK
RED
BLACK
BLACK
BLACK
BLACK
BLACK
RED
BLACK
RED
BLACK
ELACK
BLACK
RED
BLACK
WHITE
BLACK
RED
BLACK
BLACK
BLACK
RED
BLACK
RED
BLACK
BLACK
BLACK
BLACK
BLACK
RED
BLACK
BLACK
ELACK
BLACK
BLACK
BLACK
GREEN
BLACK
BLACK
ELACK
BLACK
BLACK
GREEN
GREEN
GREEN
BLACK
ELACK
BLACK
BLACK
BLACK
GREEN
BLACK
BLACK
BLACK
Given lists to be used in your code:
colourLookup - [["
"000", "FF", "FO0"1,
["000", "BLACK", "BLUE_15", "BLACK15"1,
["FFF", "YELLON15", "WHITE", "YELLOW"],
["00F", "GREEN15",
["FF0", "RED", "MAGENTA15", "RED15"1]
"CYAN", "GREEN"1,
encodedPic = [
["000000", "000000", "000000", "FF0000", "000000", "000000", "000000"),
["000000", "000000", "FF0000", "000000",
["000000", "FF0000",
["000000", "000000",
["000000", "000000", "000000",
["000000", "000000", "000000", "0OFF00", "000000", "000000", "000000"),
["000000", "000000",
["000000", "000000", "000000", "0OFF00", "000000", "00000", "000000"]
"000000", "000000"],
"000000", "FF0000", "000000"),
"FF0000", "000000", "000000"),
"FF0000", "000000", "000000", "000000"],
"FF0000",
"000000", "FFFFFF",
"FF0000", "000000",
"OOFF00",
"0OFF00", "0OFF00",
"000000", "000000"),
Transcribed Image Text:Colour Lookup Table: 000 FOO FFF BLUE15 000 BLACK BLACK15 FFF YELLOW15 WHITE YELLOW 0OF GREEN15 CYAN GREEN FFO RED MAGENTA15 RED15 Given encoded picture: 000000 000000 000000 FF0000 000000 000000 000000 000000 000000 FF0000 000000 FFO000 000000 000000 000000 FFO000 000000 FFFFFF 000000 FF0000 000000 000000 000000 FF0000 000000 FFO000 000000 000000 000000 000000 000000 FF0000 000000 000000 00000 000000 000000 000000 OOFF00 000000 000000 000000 000000 000000 000000 00FF00 OOFF00 0OFF00 000000 000000 000000 000000 OOFF00 000000 000000 000000 Sample expected output: BLACK BLACK BLACK RED BLACK BLACK BLACK BLACK BLACK RED BLACK RED BLACK ELACK BLACK RED BLACK WHITE BLACK RED BLACK BLACK BLACK RED BLACK RED BLACK BLACK BLACK BLACK BLACK RED BLACK BLACK ELACK BLACK BLACK BLACK GREEN BLACK BLACK ELACK BLACK BLACK GREEN GREEN GREEN BLACK ELACK BLACK BLACK BLACK GREEN BLACK BLACK BLACK Given lists to be used in your code: colourLookup - [[" "000", "FF", "FO0"1, ["000", "BLACK", "BLUE_15", "BLACK15"1, ["FFF", "YELLON15", "WHITE", "YELLOW"], ["00F", "GREEN15", ["FF0", "RED", "MAGENTA15", "RED15"1] "CYAN", "GREEN"1, encodedPic = [ ["000000", "000000", "000000", "FF0000", "000000", "000000", "000000"), ["000000", "000000", "FF0000", "000000", ["000000", "FF0000", ["000000", "000000", ["000000", "000000", "000000", ["000000", "000000", "000000", "0OFF00", "000000", "000000", "000000"), ["000000", "000000", ["000000", "000000", "000000", "0OFF00", "000000", "00000", "000000"] "000000", "000000"], "000000", "FF0000", "000000"), "FF0000", "000000", "000000"), "FF0000", "000000", "000000", "000000"], "FF0000", "000000", "FFFFFF", "FF0000", "000000", "OOFF00", "0OFF00", "0OFF00", "000000", "000000"),
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Similar questions
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