English National Curriculum:
Key Stage 2
To use selection, repetition, and sequences in programs and to work with variables and various forms of input and output.
To understand that functions are like workers in computer programming. To understand the inputs and outputs of functions.
- I can explain the importance of workers (functions) in computer programming.
- I can explain how the workers (functions) operate in computer programming.
- I understand the input and output of a function.
- Each worker in computer programming has its own name and purpose.
- Most workers in computer programming have inputs and outputs.
list of activities
A function is a set of programming instructions. It changes an input to a desired output result. When the input or the function changes, the output changes as a result. We can think of functions as little robots, each designed to do a specific task.
A value that goes into a function.
A value that comes out of a function.
Functions are a way of grouping a sequence of commands / set of code under one name. Functions allow for separation of code, so we can easily use the function code again and again throughout our program.
Functions ‘Encapsulate’ a task (they combine many instructions into a single segment of code). Most programming languages provide many built in functions that would otherwise require many steps to accomplish, for example computing the square root of a number. In general, we don’t need to know how a function does what it does, only that it ‘does it’.
When a function is ‘called’ the program ‘leaves’ the current section of code and begins to execute the first line inside the function. It continues on this path until the function is complete, at which point it returns to its original position.
We can relate this to Robians that have functions they enact. We can call them to do their jobs with their name and trust them to complete their job without having to know the details.