Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def get_invalid_colors(list): There are many ways to represent colors in a computer, but one common way is to specify the intensity of three colored lights:

def get_invalid_colors(list):There are many ways to represent colors in a computer, but one common way is to specify the intensity of three colored lights: red, green, and blue. By combining these lights, computers can produce more interesting colors (for example, red and green together make yellow). Computers typically represent the intensity of the lights as values between 0 and 255 (inclusive).

This function accepts a list of tuples where each tuple represents a color with three values: one for the intensity of red, one for the intensity of green, and one for the intensity of blue. The function then returns the indices of any invalid colors in the list.

Return value: a (possibly empty) list of integers which indicate the indices of invalid colors

Assumptions:

o list will be a (possibly empty) list of tuples, each tuple will have three integer values

Notes:

o Hint: You may want to make a helper function for this...

o Curious why 255? You may remember from your readings that computers store numbers in binary. 255 is the largest binary number that can be stored in 8 bits (1 byte): 1111 1111.

Examples:

o # The method call below is given two colors: (0,0,0) and (-1,0,255) # the second color (index 1) has an invalid value for red (-1) get_invalid_colors([(0,0,0),(-1,0,255)]) [1]

o # The method call below is given two colors: (0,277,0) and (-1,0,500) # the first color (index 0) has an invalid value for green (277) # the second color (index 1) has an invalid value for red (-1) and blue (500) get_invalid_colors([(0,277,0),(-1,0,500)]) [0,1]

o # The method call below is given three colors: (30,1,0), (0,53,255), and (0,0,0) # all are valid so an empty list is returned get_invalid_colors([(30,1,0),(0,53,255), (0,0,0)]) []

python language please

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What is a modem?

Answered: 1 week ago