Practice · Python

Practice Nested Loops

Use loops within loops to process grids and pairs, tracking the complexity cost.

Nested Loopswarming python…

Beat Multiplication Grid

Write a function generate_beat_grid(n) that returns an n × n multiplication table of beats. Each cell should contain the product of its 1‑based row and column numbers (i.e., row * column). If n is zero or negative, return an empty list.

Examples

generate_beat_grid(1)  # -> [[1]]

generate_beat_grid(3)  # -> [[1, 2, 3],
#                     [2, 4, 6],
#                     [3, 6, 9]]
Press Run to see output, or Check to grade against the tests.

Want a whole course built around nested loops?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.

Practice Python: Nested Loops — CodeArcade