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
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 -> outputCode
scores = [6, 8, 10]
average = sum(scores) / len(scores)
print(average)Output
8.0
Why it works
- The list is the input.
- sum gives 24 and len gives 3.
- Dividing produces the average 8.0.
Common mistake
Not this
sum(scores) / 0Try this
sum(scores) / len(scores)Divide by the number of items, not by zero or a guessed count.