It’s a little more tricky to write a function that draws a diagonal from lower-left to upper-right for a square picture. Note that the sum of the x and the y should be equal to the number of pixels in the line.

What will be an ideal response?

```
def drawDiagonal2(picture, lineColor):
width = getWidth(picture)
for p in getPixels(picture):
x = width-getX(p)
y = getY(p)

if x==y:
setColor(p,lineColor)
```

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.

Computer Science & Information Technology

You might also like to view...

Using group policy, you can deliver certificates and their associated keys to third-party Root Certification Authorities

Indicate whether the statement is true or false

Computer Science & Information Technology

The function that converts a C-string to an integer and returns the integer value is

a. atoint b. strtoint c. strint d. atoi e. None of these

Computer Science & Information Technology