Codehs - 9.1.7 Checkerboard V2

Nested Loops

This problem is a classic introduction to and Modular Arithmetic . It asks you to draw a checkerboard pattern where the color of each square depends on its position (row and column).

Understanding the Problem

Goal:

Draw a checkerboard pattern using alternating colored squares (usually black and red or black and white). The board should have 8 rows and 8 columns. However, V2 typically introduces two key requirements: 9.1.7 Checkerboard V2 Codehs

Mistake #2: Off-by-One Errors

# This is the logic for the checkerboard pattern: # If the sum of the row and column indices is even, make it red. # Otherwise, make it black. if (row + col) % 2 == 0: pen.color("red") else: pen.color("black") Nested Loops This problem is a classic introduction

System.out.println(); // new line after each row Each row has 8 columns