A marine biologist is writing a program to locate the coordinate position of a microplastic pollution hotspot (defined as a concentration greater than 15 particles per litre) on a 4x4 monitoring grid.
Figure 1
hotspot_row = -1
hotspot_col = -1
for row_idx in range(0, 4):
for col_idx in range(0, 4):
if get_concentration(row_idx, col_idx) > 15:
hotspot_row = row_idx
hotspot_col = col_idx
Figure 2
| Column 0 | Column 1 | Column 2 | Column 3 | |
|---|---|---|---|---|
| Row 0 | 3 | 8 | 12 | 4 |
| Row 1 | 7 | 14 | 19 | 2 |
| Row 2 | 5 | 11 | 9 | 13 |
| Row 3 | 6 | 10 | 8 | 1 |
Explain the purpose of the first iteration structure (the loop with control variable row_idx) in Figure 1.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.