916 Checkerboard — V1 Codehs Fixed __exclusive__

# Loop through rows and columns to draw the checkerboard for row in range(8): for col in range(8): # Alternate between black and white squares if (row + col) % 2 == 0: fill_color = "white" else: fill_color = "black"

Many students fail the autograder because they try to print the pattern directly using strings. The assignment requires you to first create a grid (usually filled with s) and then use nested loops to change specific indices to Logic for Alternating Pattern: To get the true checkerboard effect, use the modulo operator board[i][j] = (i + j) % 2

This leads to scope errors where the autograder can't find your display logic. 916 checkerboard v1 codehs fixed

(leftIsClear()) turnLeft(); move(); turnLeft();

for each row in range(rows): for each col in range(cols): x = col * square_size y = row * square_size if (row + col) % 2 == 0: set fill color to red else: set fill color to black draw square at (x, y) with size square_size # Loop through rows and columns to draw

CodeHS often uses a custom GraphicsProgram class. Here is the for 9.1.6 Checkerboard (v1) in Java:

s) to only appear on the top and bottom sections. A common fix is to use a conditional statement like if row < 3 or row > 4: to only assign s in those specific row ranges. Step-by-Step Implementation Guide Initialize the Board: Create an 8x8 list of lists filled with zeros. my_grid = [[0] * 8 for i in range(8)] Nested Loop Assignment: Loop through every row and column. Use an Here is the for 9

# Constants SIZE = 50 # Size of one square ROWS = 8 COLS = 8