Practice · Python

Practice Accumulator Patterns

Build running totals, counts, and running max/min inside a loop using an accumulator variable.

Accumulator Patternswarming python…

Score Summary with Accumulators

Write a function analyze_scores that receives a list of integer scores from a sports game. It must return a 4‑tuple:

  1. The total sum of all scores.
  2. The average score as a float (0.0 for an empty list).
  3. How many scores are greater than or equal to 10.
  4. The highest score (0 for an empty list).

Examples

analyze_scores([5, 12, 7, 20])  # → (44, 11.0, 2, 20)
analyze_scores([])            # → (0, 0.0, 0, 0)
Press Run to see output, or Check to grade against the tests.

Want a whole course built around accumulator patterns?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.