9.1.7 Checkerboard V2 Codehs //top\\ ✦ Verified
The exercise is a fundamental lesson in manipulating 2D lists (nested lists) using nested for loops . While Version 1 often focuses on just filling the board, Version 2 requires a more complex logic: creating a alternating pattern of 0s and 1s, similar to a physical checkerboard. 🛠️ Problem Logic
| Mistake | Why It’s Wrong | |---------|----------------| | Using (row + col) % 2 | V2 usually asks you to avoid this and use explicit toggling | | Forgetting to toggle after each square | Results in solid columns | | Not handling even column count | Causes row starting colors to be same for all rows | | Using setFilled(false) | Unfilled squares may appear invisible or white — set fill and color explicitly |
The Checkerboard V2 project offers significant educational value, particularly in the areas of: 9.1.7 Checkerboard V2 Codehs
# Move to the next column position pen.forward(square_size)
: To get the alternating pattern, we check if the sum of the current row and column indices is even ( (i + j) % 2 == 0 ). If it is, we assign that spot a Example: At board[0][0] (even), so it becomes board[0][1] (odd), so it stays print_board The exercise is a fundamental lesson in manipulating
// Constants for easy modification (Always use constants in V2!) const BOARD_SIZE = 400; const SQUARE_SIZE = BOARD_SIZE / 8; // 50px const COLOR_A = "red"; const COLOR_B = "black";
pen = turtle.Turtle() pen.speed(0) # Fastest drawing speed pen.hideturtle() If it is, we assign that spot a
Example pattern (B = black, W = white):
Let me know what your console is saying!