Year 9 · Python · Challenge 2

Weather Data

Four days of morning, afternoon and evening temperatures — practise nested loops on rows and columns.

2D arraycounttotalaveragemax / min

Scenario: Temperatures over four days are stored in a 2D array. Each row is a day and each column is a time: Morning, Afternoon and Evening.

Data

temperatures = [
    # Morning, Afternoon, Evening
    [15, 22, 18],  # Day 1
    [14, 25, 20],  # Day 2
    [18, 28, 22],  # Day 3
    [12, 19, 15]   # Day 4
]

Your tasks

  1. Counting — count how many readings across all days were 20 degrees or higher.
  2. Totalling — calculate and print the total of the temperatures on Day 3 (row index 2).
  3. Averaging — calculate the average Afternoon temperature across all 4 days (column index 1).
  4. Maximum and minimum — find the highest Afternoon temperature and the lowest Morning temperature.
💡 Try every task in your editor first. Only reveal the solution when you have had a proper go.

Previous: Challenge 1 · Year 9 Python · Next: Challenge 3