![daniellaZemira](/avatars/42605.jpg)
daniellaZemira
12.08.2020 •
Computers and Technology
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
Solved
Show answers
More tips
- F Family and Home When and how to start introducing solid foods to your baby?...
- C Computers and Internet Keep Your Mouse Pad Clean: The Right Way to Clean It?...
- F Food and Cooking Homemade French Fries: The Ultimate Guide...
- F Food and Cooking Red Caviar: How to Choose the Best?...
- C Computers and Internet Clearing Cache: How to Speed Up Your Browser...
- S Style and Beauty How are artificial nails removed?...
- S Style and Beauty Secrets of Tying a Pareo: 5 Ways...
- F Food and Cooking Everything You Need to Know About Pasta...
Answers on questions: Computers and Technology
- H History How is an objective summary different from an argumentative essay A. A summary should include a works-cited list, but an argumentative essay should not cite others work....
- E English HELP ASAP! That anyone should think that Penelope smarter than Odysseus is a(n) idea. A) true B) novel C) heretical D) awful...
- E English How can you make someone stop calling your name all the time even though you told them not to call your name many times because they are being annoying?...
- E English A set of sentences focused on a single idea is called a A.research paper. B.paragraph. C.section. D.thesis statement....
- M Mathematics Can someone at least have an estimate of how much money you will need to buy things fro your new house.. ( I mean everything including mattresses, sofas, bed sets, blankets,...
- M Mathematics Hi, can I get some help with this question? DON T WORRY ITS JUST A ASSIGNMENT. NOT A TEST. Thank you...
- M Mathematics Please help me please :(...
- M Mathematics Select the correct answer. If function f has zeros at -3 and 4, which graph could represent function f?...
- H History Breaking history into distinct periods of time is an example of...
- M Mathematics What is the arc length of AB?...
Ответ:
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
Ответ:
No, I will not follow you on TikTok