Functions and modularity
Practice Flashcards
Flip to reveal answersWhat is a function?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Functions and modularity
Sign up free to track progress and get spaced-repetition review schedules.
Question
What is a function?
Answer
A named block of code that does one job, is given data through parameters, and hands back a result with return. Written once, it can be called anywhere and fixed in one place.
Question
What is the difference between a parameter and an argument?
Answer
The parameter is the name in the function's definition — the placeholder. The argument is the actual value supplied when the function is called.
Question
What are the benefits of modularisation?
Answer
Reusable: one definition serves every caller. Maintainable: a fix applies everywhere at once and faults trace to one function. Testable: each function can be tested on its own. And work can be split between people.
Question
Why pass values in as parameters rather than using globals?
Answer
A function told what it needs works anywhere, can be tested on its own, and cannot be broken by something changing elsewhere in the program.
Question
Why should a function return rather than print?
Answer
A returned value can be stored, compared or displayed by the caller, and the function can be tested. A function that only prints can do none of those.
Read the notes
Full study notes for Functions and modularity
Topic 6.3 hub
Programming constructs
More from Topic 6.3
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free