9.1.7 Checkerboard V2 Codehs (90% LATEST)
var NUM_ROWS = 8; var NUM_COLS = 8; var SQUARE_SIZE = getWidth() / NUM_COLS; Use code with caution. Step 2: Create a Helper Function
If your squares do not line up perfectly, double-check your SQUARE_SIZE math. Dividing getWidth() by NUM_COLS ensures a perfect fit. 9.1.7 Checkerboard V2 Codehs
row_2 = [] for i in range(8): # Even index -> 1, Odd index -> 0 if i % 2 == 0: row_2.append(1) else: row_2.append(0) my_grid.append(row_2) var NUM_ROWS = 8; var NUM_COLS = 8;
The most efficient way to determine the color is using the modulo operator (%). If (row + col) % 2 == 0, set the color to one choice (like black). Otherwise, set it to the second choice (like red). This ensures that every time you move one square to the right or one square down, the color flips, creating the perfect checkerboard pattern. Implementation Tips row_2 = [] for i in range(8): #











