9.1.6 Checkerboard V1 Codehs -

import turtle turtle.speed(0) turtle.tracer(0) # Turn off animation for instant drawing turtle.bgcolor("white") Ask user for board size size = int(input("Enter checkerboard size (e.g., 8 for 8x8): ")) square_size = 40 # pixels per square Colors color1 = "red" color2 = "black"

for row in range(size): for col in range(size): # Alternate colors if (row + col) % 2 == 0: color = color1 else: color = color2 9.1.6 checkerboard v1 codehs

Here’s a helpful feature for the CodeHS exercise: a dynamic size input that lets you draw a checkerboard of any size (not just the default), along with a visual highlight for the current square being drawn. import turtle turtle

def draw_square(x, y, color): """Draw a single filled square at (x, y) with given color""" turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() for _ in range(4): turtle.forward(square_size) turtle.right(90) turtle.end_fill() start_x = - (size * square_size) / 2 start_y = (size * square_size) / 2 y) with given color""" turtle.penup() turtle.goto(x