Back to Topic 6.3 — Programming constructs
6.3.4Computer Science SL5 flashcards

Functions and modularity

Practice Flashcards

Flip to reveal answers
Card 1 of 56.3.4
6.3.4
Question

What is a function?

Click to reveal answer

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.

Card 1definition

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.

Card 2comparison

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.

Card 3concept

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.

Card 4concept

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.

Card 5concept

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.

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