Complete the function by filling in the missing parts. The color_translator function receives the name of a color, then prints its hexadecimal value. Currently, it only supports the three additive primary colors (red, green, blue), so it returns "unknown" for all other colors. m 1 - def color_translator(color): 2. if _== "red": 3 hex_color = "#ff0000" 4- elif == "green": 5 hex_color = "#00ff00" elif == "blue": hex_color = "#0000ff" in 0 hex_color = "unknown" return _ . 12 13 14 15 16 17 print(color_translator("blue")) # Should be #0000ff print(color_translator ("yellow")) # should be unknown print(color_translator("red")) # Should be #ff0000 print(color_translator ("black")) # should be unknown print(color_translator("green")) # Should be #00ff00 print(color translator("")) # should be unknown Run Reset

Respuesta :

Answer:

The completed program is

def color_translator(color):

      if color == "red":

             hex_color = "#ff0000"

      elif color == "green":

             hex_color = "#00ff00"

      elif color == "blue":

             hex_color = "#0000ff"

      else:

             hex_color = "unknown"

      return hex_color

Explanation:

Since the parameter in the above function is color,

This variable will serve as the name of a color and it'll be used in the conditional statements to check if the name of color is any of red, green and blue;

And that is why we have

if color == "red":

elif color == "green":

elif color == "blue":

The variable used to hold the color codes, hex_color, will be returned at the end of the function and that's why we have

return hex_color

When the program is tested with print(color_translator("blue")) and others, it prints the desired output