aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer ScienceTopic 6.3Functions and modularity
Back to Computer Science Topics
6.3.45 min read

Functions and modularity

IB Computer Science • Unit 6

AI-powered feedback

Stop guessing — know where you lost marks

Get instant, examiner-style feedback on every answer. See exactly how to improve and what the markscheme expects.

Try It Free

Contents

  • One job, written once
  • Why split a program up
  • Scope, and getting values in and out
  • Exam-style question
The big idea: A function is a named block of code that does one job, can be given different inputs, and hands back a result.

Write it once, call it anywhere — and fix it in one place when it turns out to be wrong.
Parameter and argument: The parameter is the name in the definition — the placeholder.

The argument is the actual value passed in when it is called. Definition has parameters; calls supply arguments.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime

Reusable

  • One definition serves every place that needs the job done
  • No copied blocks that then drift apart
  • A fix applies everywhere at once

Maintainable

  • Each function is small enough to understand completely
  • A fault is traced to one function, not scanned for across a program
  • It can be changed inside without touching anything that calls it

Testable and shareable

  • A function can be tested on its own, with values chosen to break it
  • Work can be split: different people write different functions
  • Both only work because the boundary is clearly defined
The copy-paste argument: Copy a calculation into four places and you have four places to fix when it is wrong — and you will miss one.

Call a function in four places and there is one.

That is the strongest single argument for modularity, and the one to write down.
Modularisation is bigger than functions: It also means grouping related functions into modules or files — all the file handling in one place, all the calculations in another.

Same idea, one level up.

Never wonder what to study next

Get a personalized daily plan based on your exam date, progress, and weak areas. We'll tell you exactly what to review each day.

Try Free Study PlanYour first topic is free to keep • No credit card required
1

In through parameters

2

Out through return

3

Local stays inside

4

Globals, sparingly

A function with no return gives nothing back: If it only prints, the value cannot be used for anything else.

return the result and print it at the call if needed — a function that returns can be tested; one that only prints cannot.

How this is tested — you must define with parameters, return a value, and say why it is better than repeating the code. It comes up two ways:

Paper 2 — working with code

  • Construct a function for a stated job, 3-5 marks
  • Explain the benefits of modularisation
  • Identify a scope error in given code

Paper 2 — the algorithmic-thinking question

  • Explain why a program should be split up
  • Reason about scope with no code shown
The classic trap: Writing a function that uses a global instead of a parameter, and prints instead of returning. It may work in the one place it was written, and it cannot be reused or tested anywhere else.
IB-style questionConstruct[5 marks]

A program calculates a percentage in four different places. Write a function for it and explain why this is better.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Functions and modularity. Write your answer and get instant AI feedback — just like a real IB examiner.

the output of the same code if the parameter is passed by reference. [2 marks]

Related Computer Science Topics

Continue learning with these related topics from the same unit:

6.1.1Variables and data types
6.1.2Substrings
6.1.3Exception handling
6.1.4Debugging
View all Computer Science topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science

Previous
6.3.3Loops
Next
Big O notation6.4.1

22 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science Topics