Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!