9.1.6 Checkerboard V1 Codehs -
Here is a solid implementation using nested loops to initialize the 2D array:
Once you've mastered "Checkerboard, v1," you can challenge yourself further:
Beepers should be placed in a checkerboard pattern (
: The create_rectangle function requires the top-left coordinate and the bottom-right coordinate 9.1.6 checkerboard v1 codehs
The final world must have a checkerboard pattern of beepers. Constraints: The solution must work on varying world sizes. Why is this Challenging?
The checkerboard has 8×8 squares, but you might accidentally loop 0 to 7 (correct) or 1 to 8 (incorrect). Fix: Always start your loop at 0 and use < ROWS and < COLUMNS .
: If the sum leaves a remainder, it colors the square white . Visual Example Matrix (Row + Col) : Top-Left cell (0,0) : →right arrow Next cell right (0,1) : →right arrow First cell second row (1,0) : →right arrow Second cell second row (1,1) : →right arrow 3. Calculating Coordinates Here is a solid implementation using nested loops
The objective of this exercise is to create a grid of alternating colored squares to form a classic checkerboard pattern. You will use the tkinter graphics library in Python to draw these shapes on a digital canvas. This assignment focuses on mastering nested loops, grid coordinates, and conditional logic. Core Concepts Explained
⚠️ Some CodeHS courses include a related exercise, "1.17.6: Checkerboard Karel," which involves using Karel the Dog to paint a checkerboard pattern by moving and placing beepers. However, the 9.1.6 exercise is specifically about creating a 2D list data structure in Python.
: The CodeHS library is strictly case-sensitive. Capitalize Rect and use uppercase properties like Color.RED and Color.BLACK . The checkerboard has 8×8 squares, but you might
This exercise is designed to test your ability to work with (lists of lists) and nested for loops . A common mistake is just printing the pattern; however, the CodeHS autograder specifically checks if you have assigned the value 1 to elements within your board. 1. Initialize Your Grid
for these requirements, or are you looking for the logic behind Checkerboard v2
This exercise focuses on using nested loops modulus operator
Never try to move() if you are at a wall. This will cause a Karel crash.
Iterate through every row and column. Use an if statement to identify the top three and bottom three rows.