Functions & Programming Concepts · Level 1 of 5
Function
A rule or callable that maps inputs to outputs or performs a computation.
Mathematical functions assign one output to each valid input; program functions may also have side effects.
Example
A routine accepts two numbers and returns their sum.
Listen to the definition and example
Audio transcript
Function. A rule or callable that maps inputs to outputs or performs a computation. Mathematical functions assign one output to each valid input; program functions may also have side effects. For example: A routine accepts two numbers and returns their sum.
Explore this concept
A useful analogy
A machine with an input contract and a specified way to produce a result.
Why it matters
This helps you distinguish a computation’s contract, inputs, outputs, and behavior.
Technical detail
A mathematical f: X → Y assigns exactly one y to each x in X. Program callables may instead mutate state, throw errors, or not terminate.
Common misconception
Not every programming function is a pure mathematical mapping.
Quick recall question
Try answering before looking back at the definition.