9.1.6 Checkerboard V1 Codehs !!better!! -
By mastering this exercise, you aren't just drawing a grid; you are learning how data is structured in almost every modern software application—from Excel spreadsheets to the pixels on your monitor.
To draw a grid, you cannot just use a single loop. You need a structure: Outer Loop (Rows): Controls the vertical position ( coordinate). Inner Loop (Columns): Controls the horizontal position ( coordinate) within that specific row.
If your actual CodeHS prompt differs, tell me the exact statement and I will adapt this write-up. 9.1.6 checkerboard v1 codehs
Write a program that draws a checkerboard pattern. Your program should create a canvas of 400x400 pixels. The checkerboard should have 8 rows and 8 columns of squares. Each square should be 50x50 pixels. Alternate the colors between black and gray (or red and black, depending on the version). The top-left square should be gray.
To solve this, you need to understand two fundamental concepts: By mastering this exercise, you aren't just drawing
The output should be an , but the requirement for this version is specific: the grid needs to have 1's on the top three rows and the bottom three rows , arranged in an alternating pattern. The middle two rows remain completely blank (filled with 0's). The final board should visually resemble the typical starting position of a checkers board.
if the prompt specifically requests them, as simply printing the pattern without storing it in a grid may cause errors. Typical Pitfalls Incorrect Function Placement : Defining the print_board function inside another block or incorrectly indenting it. Missing Middle Rows Inner Loop (Columns): Controls the horizontal position (
If you are a CodeHS teacher, you have access to excellent resources to help your students succeed.
Square Size=Canvas WidthNumber of ColumnsSquare Size equals the fraction with numerator Canvas Width and denominator Number of Columns end-fraction