← Python Foundations
16 / 27
Lesson 16 — Putting it together
Putting it together
Real programs combine everything: a function to organise the logic, a loop to go through numbers, and an if to pick the ones you want.
Why it matters: breaking a task into these building blocks is exactly how experienced developers solve big problems — one small piece at a time.
Tip: the % (modulo) operator gives the remainder, so i % 2 == 0 is true only for even numbers.
Want it another way?
Task
Finish sum_even so it returns the sum of even numbers from 1 to n. Print it for n=10.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.