Choose the answer from image 2 to fill in the blanks. Just need the answer, expl
ID: 3740985 • Letter: C
Question
Choose the answer from image 2 to fill in the blanks. Just need the answer, explanation not necessary. The second blank has the same answer options as the first blank.
QUESTION 4 In Pytbon, colours can be represented in anumber of ways: as the colour name (a string), as a hexadecimal number (string preceded with" representing one of (Red, (G)reen and B)lve). and as RGB alues (a sequence of 3 integers in the range 0 to 255 inclusive, each Consider the following Python data structure, which contams data representing the name, bexadecimal value and KGB values of some colours colours [ [ ' black ' , ' #000000' , ' #FFFFFF' , [0, 0, 011 , [250, 250, 250] ] , ('white' , [ ' red' , ' #FF0000' , [250, 0, 011 , [ 'green' , ' #00FF00' , [0, 250, 0] ] , ('blue ' , ' #0000FF' , [0, 0, 250] ] ] complete the following code to produce a list of all the green RGB values (ie, the second value in the RGB sequence) in the list coloura, i e, the sequence of values o, 250, 0, 250, 0. for greens.appendExplanation / Answer
First blank should be colour in colours this will loop thru all the tuple item in the clours
Then the second blank should be colour[2][1] this will read the 3 item in the each color first then extract GREEN value from the tuple .
Code
colours = [['black','#000000',[0,0,0]],['white','#FFFFFF',[250,250,250]],['red','#FF0000',[250,0,0]]]
greens = []
for colour in colours:
print colour
greens.append(colour[2][1])
print greens
Output
[0, 250, 0, 250, 0]