Imagine that you have a picture, and you are painting a copy of it. But you have only eight colors. Write a function that inputs a picture, and makes these changes to each pixel. For each of red, green, and blue, if the component is less than 100, make it zero. Otherwise, make it 255.

What will be an ideal response?

```
def paintLimited(picture):
for p in getPixels(picture):
valueR = getRed(p)
if valueR<100:
setRed(p,0)
else:
setRed(p,255)
valueG = getGreen(p)
if valueG<100:
setGreen(p,0)
else:
setGreen(p,255)
valueB = getBlue(p)
if valueB<100:
setBlue(p, 0)
else:
setBlue(p,255)
```

Computer Science & Information Technology

You might also like to view...

Spanning-Tree Protocol is used with which of the following network devices?

A. Router B. NIC C. Switch D. DHCP server

Computer Science & Information Technology

The code int *p; declares p to be a(n) ____ variable.

A. new B. num C. pointer D. address

Computer Science & Information Technology