9.1.7 Checkerboard V2 Codehs New! (2024)
Checkerboard V2 CodeHS
Overview
Create a checkerboard pattern using a loop to iterate over a grid of squares.
- Grid size: The 8x8 grid size provides a clear and recognizable checkerboard pattern. However, students may experiment with different grid sizes to explore how the pattern changes.
- Color selection: The choice of black and white as the primary colors provides a high-contrast and visually striking pattern. Students may choose to experiment with other color combinations to create different effects.
- Symmetry: The checkerboard pattern relies on symmetry to create a sense of order and balance. Students must ensure that their implementation maintains this symmetry.
# Draw the square
pen.begin_fill()
for i in range(4):
pen.forward(square_size)
pen.left(90)
pen.end_fill()
- Size: V2 often requires a specific board size (e.g., 400x400 pixels, each square 50x50 pixels).
- Looping Structure: V2 usually forces you to use two nested
for loops (one for rows, one for columns).
- Color Logic: You cannot hardcode colors. You must use a mathematical condition (like
(row + column) % 2 == 0) to determine the color.
- Efficiency: V2 solutions that work but are poorly structured (e.g., drawing 64 individual squares with hardcoded coordinates) will often fail the autograder.
Design Considerations
pen.forward(square_size) moves the turtle to the right after drawing a square, preparing for the next one in the row.
- The block of code after the inner loop (
pen.backward...) handles the "Carriage Return." It moves the turtle all the way back to the left edge and shifts it down one row so the next row can be drawn.
Mastering the Checkerboard V2 (9.1.7) in CodeHS To successfully complete the 9.1.7 Checkerboard V2 exercise in CodeHS, you must generate an 9.1.7 Checkerboard V2 Codehs