How would you rotate a 2D array 180 degrees and 90 degrees?
Implement rotate_matrix(matrix, degrees) for a non-empty rectangular matrix. Return a new matrix rotated clockwise by either 90 or 180 degrees, without modifying the input matrix. A 90-degree rotation may change the matrix dimensions.
def rotate_matrix(matrix, degrees):