1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
agasfer [191]
3 years ago
14

#this is 34 lines -- you can do it! # #In web development, it is common to represent a color like #this: # # rgb(red_val, green_

val, blue_val) # #where red_val, green_val and blue_val would be substituted #with values from 0-255 telling the computer how much to #light up that portion of the pixel. For example: # # - rgb(255, 0, 0) would make a color red. # - rgb(255, 255, 0) would make yellow, because it is equal # parts red and green. # - rgb(0, 0, 0) would make black, the absence of all color. # - rgb(255, 255, 255) would make white, the presence of all # colors equally. # #Don't let the function-like syntax here confuse you: here, #these are just strings. The string "rgb(0, 255, 0)" #represents the color green. # #Write a function called "find_color" that accepts a single #argument expected to be a string as just described. Your #function should return a simplified version of the color #that is represented according to the following rules: # # If there is more red than any other color, return "red". # If there is more green than any other color, return "green". # If there is more blue than any other color, return "blue". # If there are equal parts red and green, return "yellow". # If there are equal parts red and blue, return "purple". # If there are equal parts green and blue, return "teal". # If there are equal parts red, green, and blue, return "gray". # (even though this might be white or black). #Write your function here!
Computers and Technology
1 answer:
Ahat [919]3 years ago
6 0

Answer:

Following are the code to this question:

def find_color(color):#definig a method find_color that accepts color parameter

   color = str(color).replace('rgb(', '').replace(')', '')#definig color variable that convert parameter value in string and remove brackets

   r, g, b = int(color.split(', ')[0]), int(color.split(', ')[1]), int(color.split(', ')[2])#defining r,g,b variable that splits and convert number value into integer

   if r == g == b:#defining if block to check if r, g, b value is equal

       return "gray"#return value gray

   elif r > g and r > b:#defining elif block that checks value of r is greater then  g and b

       return "red"#return value red

   elif b > g and b > r:#defining elif block that checks value of b is greater then g and r

       return "blue"#return value blue

   elif g > r and g > b:#defining elif block that checks value of g is greater then r and b

       return "green"#return value green

   elif r == g:#defining elif block that checks r is equal to g

       return "yellow"#return value yellow

   elif g == b:#defining elif block that checks g is equal to b

       return "teal"#return value teal

   elif r == b:#defining elif block that checks r is equal to b

       return "purple"#return value purple

print(find_color("rgb(125, 50, 75)"))#using print method to call find_color method that accepts value and print its return value

print(find_color("rgb(125, 17, 125)"))#using print method to call find_color method that accepts value and print its return value

print(find_color("rgb(217, 217, 217)"))#using print method to call find_color method that accepts value and print its return value

Output:

red

purple

gray

Explanation:

In the above method "find_color" is declared that uses the color variable as the parameter, inside the method a color variable is declared that convert method parameter value into the string and remove its brackets, and three variable "r,g, and b" is defined.  In this variable first, it splits parameter value and after that, it converts its value into an integer and uses the multiple conditional statements to return its calculated value.

  • if block checks the r, g, and b value it all value is equal it will return a string value, that is "gray" otherwise it will go to elif block.
  • In this block, it checks the value of r is greater then g, and b if it is true it will return a string value, that is "red" otherwise it will go to another elif block.  
  • In this block, it checks the value of b is greater then g, and r if it is true it will return a string value, that is "blue" otherwise it will go to another elif block.    
  • In this block, it checks the value of g is greater then r and b if it is true it will return a string value, that is "green" otherwise it will go to another elif block.    
  • In the other block, it checks r is equal to g or g is equal to b or r is equal to b, it will return the value, that is "yellow" or "teal" or "purple".
You might be interested in
What is the definition of legal intrusion
AleksAgata [21]
My answer -

intrusion of rights, right of privacy, trespass

P.S

Happy to help you have an AWESOME!!! day ^-^
5 0
3 years ago
A vlan ________.
tensa zangetsu [6.8K]

A vlan can span multiple interconnected switches.

<h3>What is a vlan?</h3>

A virtual LAN (VLAN) is a logical overlay network that groups together a subset of devices that share a physical LAN, isolating the traffic for each group.

A LAN is a group of computers or other devices in the same place -- e.g., the same building or campus -- that share the same physical network.

Each virtual switch, or VLAN, is simply a number assigned to each switch port.

For example, the two switch ports in the red mini-switch might be assigned to VLAN #10 . The two ports in the orange mini-switch might be assigned to VLAN #20 .

VLANs can be used for different groups of users, departments, functions, etc., without needing to be in the same geographical area.

VLANs can help reduce IT cost, improve network security and performance, provide easier management, as well as ensuring network flexibility.

To learn more about vlan, refer

https://brainly.in/question/2890503

#SPJ4

6 0
2 years ago
Read the scenario and answer the question. Audrey had problems with her computer software recently. One of her programs shut dow
Sophie [7]

Answer:

Refer to the troubleshooting checklist.

Explanation:

I got it right in edge:)

6 0
3 years ago
Read 2 more answers
What is destination email address​
Ronch [10]

Answer:

Explanation:

The E-mail Destination allows you to send data from your forms in text format to various different email addresses.

8 0
3 years ago
Im bored, any anime recommendations? i probably watched whatever youre gonna say
Alex777 [14]

Answer:

Hi..

Explanation:

i have seen a lot of anime shows XD hunter x hunter, dbz, black clover, 7 deadly sins

3 0
3 years ago
Read 2 more answers
Other questions:
  • Sarah is creating and formatting a newsletter for her school. Which page layout rules should she consider when doing this?
    13·2 answers
  • Why would an IT technician ever have to change out a computer’s motherboard?
    5·2 answers
  • How much days are in a year
    9·2 answers
  • You are the network administrator for Slimjim, a peripheral device company. The network uses Linux, and you need information on
    10·1 answer
  • What is the difference between C and C++. If I know C, will it be hard to lean C++?
    15·1 answer
  • How can forms help us reduce data-entry errors?
    12·1 answer
  • Software and technology that allow people to work together on a task are known as
    8·2 answers
  • Which Excel function or tool will you use to display the cells that are referred to by a formula in the selected cell
    8·1 answer
  • Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and th
    12·1 answer
  • What is one of the limitations of marketing in social media?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!