python
Start with my solution to the rotateLeft function. Modify it to rotate right 90 degrees, instead.
def rotateLeft(oldPic): w = oldPic.getWidth() h = oldPic.getHeight() newPic = Picture(h, w) for x in range(w): for y in range(h): oldColor = oldPic.getColor(x, y) newX = y newY = w - x - 1 newPic.setColor(newX, newY, oldColor) return newPic |
RAW CODE
def rotateRight(oldPic):
w = oldPic.getWidth()
h = oldPic.getHeight()
newPic = Picture(h, w)
for x in range(w):
for y in range(h):
oldColor = oldPic.getColor(x, y)
newX = h - y - 1 ### NEW INDEX FOR X
newY = x ### NEW INDEX FOR Y
newPic.setColor(newX, newY, oldColor)
return newPic
SCREENSHOTS
##### FOR ANY QUERY, KINDLY GET BACK, THANKYOU. #####
Get Answers For Free
Most questions answered within 1 hours.