Ibnovate Course 2 · The Rising Builders
⏱ 75 minLive session · ages 12–15

Session 2 — Playing with Data

Duration: 75 min · Format: live online · Ages: 12–15

Session goal: by the end, students can store many values in a list, loop through them, and compute a total, an average, and the maximum.

Before class — prep (5 min)

Agenda

Time Segment
0:00 Hook — one variable per value doesn't scale (5 min)
0:05 Teach — a list holds many values (13 min)
0:18 Teach — a loop repeats for every item (15 min)
0:33 Activity — analyse your own week's data (25 min)
0:58 Check for understanding (10 min)
1:08 Wrap-up + homework (7 min)

0:00 · Hook (5 min)

Ask the class and take a few answers (chat or unmute):

Let them react, then land it: data science means handling thousands of values at once. Today they learn the two tools that make that possible — a list holds all the values in one place, and a loop processes them in just a few lines.


0:05 · Teach — A list holds many values (13 min)

Explain: a list stores many values in order. Each value has a position called an index, and indexes start at 0, not 1.

Share this diagram and trace the loop visiting each number to build a total:

A list of four numbers and a loop that visits each one to make a total of 53

Type/run this together in Colab:

scores = [12, 7, 25, 9]

print(scores[0])      # 12  (first item)
print(len(scores))    # 4   (how many)

Ask: "Why does scores[0] give 12 and not 7?" (Answer: lists start counting at 0, so index 0 is the first item.)

⚠ Watch for the off-by-one trap: students expect scores[1] to be the first item. It's actually the second. Counting from 0 is the single most common list mistake — call it out early.


0:18 · Teach — A loop repeats for every item (15 min)

Explain: a for-loop runs the same steps for each item — whether the list has 4 numbers or 4 million. Point out the indentation: the indented line runs once per item.

Type/run this together in Colab:

scores = [12, 7, 25, 9]
total = 0

for s in scores:
    total = total + s     # add each score to the total

print("Total:", total)          # 53
print("Average:", total / len(scores))   # 13.25
print("Highest:", max(scores))  # 25

Walk through one pass of the loop out loud: total starts at 0, then becomes 12, then 19, then 44, then 53.

Ask: "What would happen if we put print("Total:", total) inside the loop, indented?" (Answer: it would print the running total four times, not once.)

⚠ Watch for: Python has handy shortcuts — sum(scores), max(scores), min(scores) — and students may reach for them straight away. That's fine, but make sure they can also explain how the loop builds the total underneath. That's what makes them a real coder.


0:33 · Activity — Analyse your own data (25 min)

Have students open Google Colab and analyse a real list from their own life. Screen-share your notebook as a model.

Type/run this together in Colab:

sleep = [8, 7, 6, 9, 7, 10, 8]

Then have them: 1. Use a loop (or sum) to print the total and the average. 2. Print the most and least with max() and min(). 3. Bonus: count how many nights they slept 8 or more hours using a loop and an if.

Circulate for (or watch the chat for) the classic "biggest" bug. Share this broken code and ask why it only ever prints 9:

scores = [12, 7, 25, 9]
for s in scores:
    biggest = s
print(biggest)

Ask: "Why is biggest always the last number?" Then fix it live: biggest is overwritten every loop, so it ends on the last item. To find the real biggest, start biggest = scores[0], then inside the loop if s > biggest: biggest = s. (Or just use max(scores).)


0:58 · Check for understanding (10 min)

Ask these aloud or drop them in the chat. Answer key (for you):

  1. What is scores[0] in scores = [12, 7, 25, 9]?12 — lists start counting at 0, so index 0 is the first item.
  2. What does a for-loop do? → Runs the same steps for every item in a list, automatically.
  3. How do you get the average of a list?sum(list) / len(list) — the total divided by how many items.

1:08 · Wrap-up + homework (7 min)


Teaching notes

A DataFrame table with columns name, age, score and rows 0, 1, 2

```python import pandas as pd

# load a real, public dataset (thousands of rows!) url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv" df = pd.read_csv(url)

print(df.shape) # (rows, columns) df.head() # peek at the first 5 rows print(df["body_mass_g"].mean()) # average penguin mass ```

Explain that real data has gaps — df = df.dropna() removes empty rows, then check df.shape again. Challenge them to print the average of another column, and the count of each species with df["species"].value_counts(). - Low-tech fallback: if devices can't run Colab, work the scores = [12, 7, 25, 9] loop by hand on the shared screen — write the value of total after each pass — then have students trace their own sleep list on paper before typing it up later.

Vocabulary

Term Meaning
List Many values stored in order
Index An item's position (starts at 0)
Loop Repeating steps for each item
Average / Mean Total ÷ how many
DataFrame A table of data in Pandas

Resources

Next session

Session 3 — Your First Prediction: students build a real model that learns a pattern from data and predicts a new value with scikit-learn.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒