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.
Practise AQA GCSE Computer Science Programming concepts with exam-style questions for GCSE Computer Science. 100 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.