These worksheets are free forever. Want lessons that adapt to your child as they learn, plus progress tracking? Try Ignition Learning free.

Sign up free

Ignition Learning — Activity Sheet

Functions & modular programming

Technologies · Year 10

Name: ______________________Date: ____________

A function is a named, reusable block of code that performs a specific task — you can "call" it whenever needed instead of rewriting the same code repeatedly. Functions can accept inputs (parameters) and return outputs. Modular programming means breaking a large program into smaller, focused functions or modules, making code easier to read, test, debug and reuse.

Example

Instead of writing the code to calculate a total price with tax five separate times in a program, you'd write one function calculateTotal(price, taxRate) that takes those inputs and returns the total — then call that same function every time you need it.

Key terms

Function:
A named, reusable block of code that performs a specific task.
Parameter:
An input value a function accepts.
Modular programming:
Breaking a program into smaller, focused, reusable pieces.

Questions

  1. 1. A function is:

    • A named, reusable block of code
    • A single, unchangeable value
    • A type of hardware
    • A password
  2. 2. A parameter is:

    • An input value a function accepts
    • The function's name only
    • A type of loop
    • A type of variable that never changes
  3. 3. Modular programming means:

    • Breaking a program into smaller, focused pieces
    • Writing all code in one giant block
    • Avoiding any structure at all
    • Using no functions whatsoever
  4. 4. Functions help avoid:

    • Repeating the same code multiple times
    • Using any variables
    • All forms of structure
    • Testing code
  5. 5. A function can "return":

    • An output value
    • Only errors
    • Nothing, ever
    • Only text, never numbers
  6. 6. "Calling" a function means:

    • Running that block of code
    • Deleting the function permanently
    • Renaming the function
    • Ignoring the function entirely
  7. 7. Breaking a large program into smaller functions makes it:

    • Easier to read, test and debug
    • Impossible to understand
    • Slower with no other benefit
    • Harder to maintain
  8. 8. A function calculateTotal(price, taxRate) has how many parameters?

    • 2
    • 1
    • 0
    • 3
  9. 9. Why is it useful to reuse a function rather than copying and pasting the same code repeatedly?

    • Changes only need to be made in one place, reducing errors and repeated work
    • Copying code is always more efficient than reusing functions
    • Reusing functions always breaks a program
    • There is no meaningful benefit to reusing code
  10. 10. A function with no parameters:

    • Can still perform a task, just without external input
    • Is impossible to create
    • Always causes an error
    • Cannot return any value
  11. 11. Testing a single function in isolation is generally:

    • Easier than testing an entire large program at once
    • Impossible to do
    • Exactly as difficult as testing everything together
    • Never useful for finding bugs
  12. 12. A "module" in programming generally refers to:

    • A self-contained piece of code with a specific purpose, often containing related functions
    • A single character in the code
    • A type of hardware component
    • A password requirement
  13. 13. If a bug is found in a function used in 10 places in a program, fixing it in the function definition:

    • Fixes it everywhere that function is used
    • Only fixes one of the 10 places
    • Requires fixing all 10 places separately
    • Has no effect on the bug
  14. 14. Giving a function a clear, descriptive name (like calculateTotal) mainly helps:

    • Other programmers (and yourself later) understand what it does
    • Make the program run faster
    • Replace the need for any comments ever
    • Nothing at all
  15. 15. Why might a large program with no functions (all code in one long block) be harder to maintain over time?

    • Related logic isn't clearly separated, making changes riskier and harder to trace
    • Code with no functions is always easier to maintain
    • Function-free code has no real downsides
    • Maintenance difficulty has no connection to code structure
  16. 16. Why might breaking a large program into modules make it easier for a team of programmers to work together?

    • Different people can work on different modules independently without constantly interfering with each other's code
    • Modules always make teamwork more difficult
    • Only one person can ever work on a modular program at a time
    • Modular structure has no effect on team collaboration
  17. 17. Why is it good practice for a function to do one clear, specific task rather than many unrelated things?

    • It becomes easier to understand, test, reuse and debug when its purpose is focused
    • A function should always try to do as many different things as possible
    • Function focus has no impact on code quality
    • Combining many unrelated tasks always improves a function
  18. 18. Why might a well-designed function be reusable across completely different programs, not just the one it was originally written for?

    • A focused, general-purpose function with clear inputs and outputs can often solve a similar problem elsewhere
    • Functions can only ever be used in the exact program where they were first written
    • Reusability across programs is never a realistic goal
    • Functions become useless once their original program is finished
  19. 19. Why do experienced programmers often say "don't repeat yourself" (DRY) when writing code?

    • Repeated code increases the risk of inconsistent fixes and makes maintenance harder
    • Repeating code is always the most efficient approach
    • DRY has no real benefit to code quality
    • Repetition makes code easier to maintain than using functions
  20. 20. Why might a function that both performs a calculation AND prints output directly to the screen be considered less flexible than one that just returns a value?

    • A function that only returns a value can be reused in more contexts, since the caller decides what to do with the result
    • Printing directly is always more flexible than returning a value
    • Flexibility has no connection to how a function is structured
    • Functions should never return any value at all
  21. 21. Why do many programming languages let a function call another function (nested calls), such as a total() function calling a smaller tax() function inside it?

    • It allows complex tasks to be built up from smaller, already-tested building blocks
    • Functions are never allowed to call other functions in any language
    • Nested function calls always cause a program to crash
    • This practice has no relationship to modular programming

Answer key (parent copy)

  1. 1. A named, reusable block of code
  2. 2. An input value a function accepts
  3. 3. Breaking a program into smaller, focused pieces
  4. 4. Repeating the same code multiple times
  5. 5. An output value
  6. 6. Running that block of code
  7. 7. Easier to read, test and debug
  8. 8. 2
  9. 9. Changes only need to be made in one place, reducing errors and repeated work
  10. 10. Can still perform a task, just without external input
  11. 11. Easier than testing an entire large program at once
  12. 12. A self-contained piece of code with a specific purpose, often containing related functions
  13. 13. Fixes it everywhere that function is used
  14. 14. Other programmers (and yourself later) understand what it does
  15. 15. Related logic isn't clearly separated, making changes riskier and harder to trace
  16. 16. Different people can work on different modules independently without constantly interfering with each other's code
  17. 17. It becomes easier to understand, test, reuse and debug when its purpose is focused
  18. 18. A focused, general-purpose function with clear inputs and outputs can often solve a similar problem elsewhere
  19. 19. Repeated code increases the risk of inconsistent fixes and makes maintenance harder
  20. 20. A function that only returns a value can be reused in more contexts, since the caller decides what to do with the result
  21. 21. It allows complex tasks to be built up from smaller, already-tested building blocks