Complete the code to declare the base class for all pieces.
class [1]: def __init__(self, color): self.color = color
The base class for all pieces should be named Piece to represent any game piece.
Complete the code to define the board class with a grid attribute.
class [1]: def __init__(self, rows, cols): self.grid = [[None for _ in range(cols)] for _ in range(rows)]
The class representing the game board should be named Board and contain a grid attribute.
Fix the error in the piece subclass definition for a chess knight.
class Knight([1]): def __init__(self, color): super().__init__(color)
The Knight class should inherit from the base Piece class.
Fill both blanks to complete the method that moves a piece on the board.
def move_piece(self, from_pos, to_pos): piece = self.grid[1]from_pos[0]][from_pos[1]] self.grid[2]to_pos[0]][to_pos[1]] = piece
To access and assign elements in a 2D list, square brackets [ ] are used.
Fill all three blanks to complete the dictionary comprehension that maps piece names to their counts.
piece_counts = [1]: [2] for [3] in pieces}
The dictionary comprehension maps each piece's name to how many times it appears in the list.