Grade 9 · Media & Informatics
Break a problem into smaller functions (modules) with inputs to make a program clearer.
You already know that a function is a named, reusable set of steps. Modular programming takes that idea further: instead of writing one long program, you break the problem into several small functions, each doing one clear job. Together these modules solve the whole task, but each piece stays small enough to understand on its own.
A well-made function usually takes an input (often called a parameter) and gives back a result, without needing to know about the rest of the program. One function might check whether a password is long enough, another might greet a user by name, and a third might work out a total. You then combine them — and reuse each one wherever it is needed.
Why bother? Because small, well-named pieces are far easier to read, to test and to fix. If something goes wrong, you can look at one function instead of hunting through hundreds of lines. And when you need the same job done again, you simply call the module you already wrote rather than copying code. Breaking a big problem into smaller parts is one of the most useful habits in all of computing.
Have a go right here. Nothing is saved and you can retry as much as you like. Create a free account when you want to save your progress and get Archie, your tutor.
Create a free account to save your progress, track mastery and ask Archie, your tutor, for a hand.
Already with us? Open this lesson in learncoach.ch for mastery tracking and Archie, your tutor.