<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def color_square(self, x, y, unit_coords=False):
 """ Handles actually coloring the squares """

        # Calculate column and row number
        if unit_coords:
            col = x
            row = y
        else:
            col = x//self.col_width
            row = y//self.row_height

        # If the tile is not filled, create a rectangle
        if not self.tiles[row][col]:
            self.tiles[row][col] = \
                self.c.create_rectangle(col*self.col_width,
                                        row*self.row_height,
                                        (col+1)*self.col_width,
                                        (row+1)*self.row_height,
                                        fill="black")
            self.cells.append(row*self.cols + col)

        # If the tile is filled, delete the rectangle and clear the reference
        else:
            self.c.delete(self.tiles[row][col])
            self.tiles[row][col] = None
            self.cells.remove(row*self.cols + col)