Studyfin Studyfin ✨ Sign up free

Lists & arrays

Grade 10 · Coding · Free lesson

Hey there! Ready to level up your coding skills? Let's explore how programmers organize lots of data using lists!

Imagine you are designing a video game and need to store the names of ten high scores. Instead of creating ten separate variables, we use a single list to hold them all together.

A list, or array, is an ordered collection of items stored under one name. Each item has a specific position called an index, which always starts counting at zero.

An Array is a Row of Numbered Boxes "Alex" "Sam" "Charlie" Index [0] Index [1] Index [2]

To solve complex problems, we can use a software design process. We break down the main goal into subproblems, like creating a nested loop to search through rows and columns of data.

Nested Loops: Row by Row Search Outer loop selects row, Inner loop scans items!
✏️ Worked example

Use a software design process to write a nested loop program that searches a 2D grid of student scores to find any score below 60.

  1. 1. Identify the subproblems: First, we need to loop through each row. Second, we need to loop through each column inside that row.
  2. 2. Create the outer loop: This loop will keep track of our row index as we move down the grid.
  3. 3. Create the inner loop: Inside the first loop, make a second loop to check every individual score in the active row.
  4. 4. Add the condition: Use an 'if' statement to check if the current score at grid[row][col] is less than 60.
  5. 5. Print the result: If a score is below 60, print its position so teachers can offer support!
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons