Module 14 of 15 · Step 1 of 15

Mixed Practice

Real programs use several beginner ideas at once. Work one step at a time: inspect the data, decide what must repeat, decide what must be tested, and choose what to return or display.

By the end of this lesson, you can:
  • Combine loops and conditions
  • Calculate an average
  • Filter list values
  • Read dictionaries in a loop
  • Build a small reusable function
Mixed Practice lesson progress0%

Course progress: 0% · 0 of 15 steps completed in this module

Learn · Plan the data and result
Concept 1 of 6

Plan the data and result

Before coding, write down the input, the desired output, and the operation that connects them. A short plan prevents random edits when a task combines several concepts.

Pattern
# input -> process -> output
Code
scores = [6, 8, 10]
average = sum(scores) / len(scores)
print(average)
Output
8.0

Why it works

  1. The list is the input.
  2. sum gives 24 and len gives 3.
  3. Dividing produces the average 8.0.

Common mistake

Not this
sum(scores) / 0
Try this
sum(scores) / len(scores)

Divide by the number of items, not by zero or a guessed count.