Using nested loops, write a function that reduces red in the top third of a picture and clears blue in the bottom third.
The question does not specify the amount to reduce red by. In this solution, a variable is passed in to determine that amount, but it could also have been hardcoded into the function.
```
def colorAffectThirds (src, redReduction):
wThird = int(getWidth(src)/3.0)
hThird = int(getHeight(src)/3.0)
wTwoThird = int(2.0*(getWidth(src)/3.0))
hTwoThird = int(2.0*(getHeight(src)/3.0))
w = (getWidth(src))
h = (getHeight(src))
for x in range(0, wThird):
for y in range(0,hThird):
p = getPixel(src, x, y)
redAmount = getRed(p)-redReduction
if redAmount <0:
redAmount = 0
setRed(p, redAmount)
for x in range(wTwoThird, w):
for y in range(hTwoThird,h):
p = getPixel(src, x, y)
setBlue(p, 0)
```
You might also like to view...
Charles Babbage designed a mechanical computer called the ________
Fill in the blank(s) with correct word
You should take at least two key documents with you to an interview-your resume and a(n) ______________________________.
Fill in the blank(s) with the appropriate word(s).