Write a function to put 10 pixel wide “prison cell bars” on the left border, center, and right border of an input picture.
What will be an ideal response?
```
def prisonbars(picture, lineColor):
width = getWidth(picture)
center = width/2
for p in getPixels(picture):
x = width-getX(p)
if x<10:
setColor(p,lineColor)
elif x>width-11:
setColor(p,lineColor)
if (x>center-5) and (x
```
Note: The question does not specify that a line color should be passed in, so one can just write a function that always uses the same color.
Additionally the middle bar is difficult to get at exactly ten pixels across and centered. The above is one way to ensure that the bar is ten pixels across, but it will only be centered in certain images with uneven widths. Another solution that is not stringent concerning the ten pixels across but will always be centered is:
```
def prisonbars(picture, lineColor):
width = getWidth(picture)
center = width/2
for p in getPixels(picture):
x = width-getX(p)
if x<10:
setColor(p,lineColor)
elif x>width-11:
setColor(p,lineColor)
difference = abs(center-x)
difference = abs(difference)
if difference<6:
setColor(p,lineColor)
```
You might also like to view...
Discuss the concepts associated with dimensionality modeling.
What will be an ideal response?
The table marked 1 in the accompanying figure has a rules value of ____.
A. all B. cols C. rows D. void
Match the following table components to their brief descriptions:
I. header row II. total row III. first column IV. banded row V. banded column A. formats even columns differently than odd columns B. last row in a table C. known as the stub D. formats even rows differently than odd rows E. used for column headings
Which Linux troubleshooting file keeps a log of mail activity?
a. Messages b. maillog c. boot.log d. Spooler