Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a function called create_colours_dictionary(colours_list) that takes a list of strings as a parameter and returns a colours dictionary from the parameter. The key of

Define a function called create_colours_dictionary(colours_list) that takes a list of strings as a parameter and returns a colours dictionary from the parameter. The key of each item in the dictionary is the colour code that we will use to draw a pixel art pattern and the value is a list containing the RGB colour components. An RGB colour value is specified with: red, green, blue. Each component (red, green, and blue) defines the intensity of the colour as an integer between 0 and 255. For example, (0, 0, 255) is rendered as blue, because the blue component is set to its highest value (255) and the others are set to 0. The format of the RGB is a list of three integers.

For example:

Test Result
colours_list = ['b:165,42,42', 'c:255,228,196', 'w:255,255,255', 'p:128,0,128', 't:210,180,140'] colour_dictionary = create_colours_dictionary(colours_list) for key in sorted(colour_dictionary.keys()): print(key, colour_dictionary[key])
b [165, 42, 42] c [255, 228, 196] p [128, 0, 128] t [210, 180, 140] w [255, 255, 255] 
colours_list = ['p:255,192,203', 'b:0,0,0', 'w:255,255,255', 'd:139,0,0'] colour_dictionary = create_colours_dictionary(colours_list) for key in sorted(colour_dictionary.keys()): print(key, colour_dictionary[key])
b [0, 0, 0] d [139, 0, 0] p [255, 192, 203] w [255, 255, 255]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

4-56. Our computers are serviced by the Santee Company.

Answered: 1 week ago

Question

LO5 Describe job analysis and the stages in the process.

Answered: 1 week ago