Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # First Exercise
- def change(source,x,y):
- # @param source: Picture
- # @param x and y: int
- if getWidth(source) != getHeight(source) or x < 0 or y < 0 or x >= getWidth(source) or y >= getHeight(source):
- repaint(source)
- else:
- for i in range(getWidth(source)):
- pixel = getPixel(source,i,y)
- pixelSec = getPixel(source,x,i)
- setColor(pixelSec,getColor(pixel))
- setColor(pixel,getColor(pixelSec))
- repaint (source)
- # Second Exercise
- def change_matrix(matrix, x, y):
- # @param matrix: matrix
- # @param x and y: int
- # return matrix
- if x < 0 or y < 0 or x > len(matrix)-1 or y > len(matrix[c])-1:
- return matrix
- for count in range(len(matrix)):
- if len(matrix[count]) != len(matrix):
- return matrix
- else:
- for i in range(len(matrix[x])):
- row = matrix[x][i]
- matrix[x][i] = matrix[i][y]
- matrix[i][y] = row
- return matrix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement