# Homework 32 solution, problem 3: grid. # Run with: python exercises/32/homework/solutions/03-grid.py import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Grid") clock = pygame.time.Clock() cols = 4 rows = 4 cell_w = 800 // cols cell_h = 600 // rows running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False screen.fill((30, 30, 30)) for row in range(rows): for col in range(cols): x = col * cell_w y = row * cell_h pygame.draw.rect(screen, (180, 180, 180), (x, y, cell_w, cell_h), 2) pygame.display.flip() clock.tick(60) pygame.quit()