Color mixer
Define a function color_mixer
that receives two colors color1
and color2
and returns the color resulting from mixing them in EITHER ORDER.
The colors received are either red
, blue
, or yellow
and you should return:
Magenta
if the colors mixed are red
and blue
Green
if the colors mixed are blue
and yellow
Orange
if the colors mixed are yellow
and red
Examples:
>>> color_mixer('red', 'blue')
'Magenta'
>>> color_mixer('blue', 'red')
'Magenta'
>>> color_mixer('blue', 'yellow')
'Green'
>>> color_mixer('yellow', 'red')
'Orange'
Test Cases
Solution 1
def color_mixer(color1, color2):
if color1 == 'blue':
if color2 == 'red':
return 'Magenta'
elif color2 == 'yellow':
return 'Green'
elif color1 == 'red':
if color2 == 'yellow':
return 'Orange'
elif color2 == 'blue':
return 'Magenta'
elif color1 == 'yellow':
if color2 == 'blue':
return 'Green'
elif color2 == 'red':
return 'Orange'