🎯Calibrate
1Fill-in
2Debug
3Extend
4Create
🧠Concept
📓Reflect
👤 Your Details REQUIRED — fill in before you begin (★ = required)
🎯 Before You Begin Calibration Check 2 questions + 1 reflection — unlocks Tier 1
Think about why we split code into functions: what does each function receive (parameters) and give back (return value)? How do you call a function correctly?
1 10 5
Tier 1 Fill in the Blanks Complete the code skeleton — 7 blanks

Complete the function definitions and calls. Fill each blank with the correct parameter, keyword, or return value.

def ▢1(screen, snake, food):
    """Draw the game world each tick."""
    screen.fill(BG)
    for i, (cx, cy) in ▢2(snake):
        colour = (0,180,60) if i == 0 else GREEN
        pygame.draw.rect(screen, colour,
            pygame.Rect(cx*CELL_SIZE, cy*CELL_SIZE, CELL_SIZE-2, CELL_SIZE-2),
            border_radius=4)
    fx, fy = food
    pygame.draw.circle(screen, RED,
        (fx*CELL_SIZE+CELL_SIZE//2, fy*CELL_SIZE+CELL_SIZE//2), CELL_SIZE//3)
    pygame.display.▢3()

def spawn_food(snake):
    """Return a random food position not overlapping snake."""
    while True:
        pos = (random.randint(0,GRID_COLS-1), random.randint(0,GRID_ROWS-1))
        if pos ▢4 snake:
            ▢5 pos

# ── inside the game loop ──
draw(▢6, snake, food)
food = spawn_food(▢7)
1.Blank 1: d___
2.Blank 2: e________
3.Blank 3: f___
4.Blank 4: n_____
5.Blank 5: r_____
6.Blank 6: s_____
7.Blank 7: s____
Tier 2 Find & Fix the Bugs 3 bugs to correct

The function definitions below have 3 bugs. Type the corrected line for each.

def draw(snake, food):    # Bug 1 – missing parameter
    screen.fill(BG)
    # ... drawing code ...
    pygame.display.flip()

def spawn_food(snake):
    while True:
        pos = (random.randint(0,GRID_COLS-1), random.randint(0,GRID_ROWS-1))
        if pos not in snake:
            pass          # Bug 2 – nothing is returned

font = pygame.font.SysFont("Arial", 20, bold=True)
def draw_score(score):
    surf = font.render(f"Score: {score}", True, WHITE)
    screen.blit(surf, (8, 6))

# In the game loop:
draw(snake)               # Bug 3 – missing argument

Bug 1

Buggy line:

def draw(snake, food):

Your fix:

Hint: The function draws onto `screen` but never receives it — add it as the first parameter.

Bug 2

Buggy line:

pass # Bug 2 – nothing returned

Your fix:

Hint: The function finds a valid position but never hands it back. What keyword sends a value out of a function?

Bug 3

Buggy line:

draw(snake)

Your fix:

Hint: The call must pass every argument the function signature requires — check how many parameters draw() has.

Reflection 2 Mid-Point Check-In
Tier 3 Extend the Code Add the feature described below

Write a `draw_score(screen, score)` function that renders the score in the top-left corner using `pygame.font.SysFont`. Make sure `screen` is a parameter, not a global.

font = pygame.font.SysFont("Arial", 20, bold=True)

def draw_score(screen, score):
    # YOUR CODE: render f"Score: {score}" in WHITE
    # blit it at position (8, 6)
    pass

# Call it inside your draw() function:
# draw_score(screen, score)
Tier 4 Create from Scratch Open-ended challenge

**Challenge:** Refactor the entire drawing pipeline so `draw()` calls `draw_score()` internally. Then write a second function `draw_grid(screen)` that overlays a faint grid on the background. Paste both functions and explain how you chose their parameters.

🧠 Concept Check Test Your Understanding 5 quick questions — required before the Reflective Journal 🔒

Answer all 5 questions, then the Reflective Journal will unlock.

1. Why is str(score) needed in: 'Score: ' + str(score)?

2. What does score += 1 mean?

3. if score % 5 == 0: level += 1 — this triggers when:

4. To restart the game when R is pressed, which code is correct?

5. Increasing level speed means:

📓 Reflective Journal 5 prompts — required before Step 5 is marked complete 🔒

Answer each prompt thoughtfully. There are no right or wrong answers — this is your own reflection.

🎯 Post-Activity Check-In After Completing All Tiers Complete after the Reflective Journal to finish this step 🔒
1. How confident do you feel about this step’s concepts now? (1 = not confident, 10 = very confident)
1 10 5
2. Your Tier 1 first-attempt score (auto-filled)
%