Homonym: function (Role)
A "function" is a specific relationship or rule that connects an input to an output. In mathematics, a function takes a number (input), applies a certain operation, and produces another number (output). For example, the function f(x) = 2x doubles any number you put into it.
In computer programming, a function is a block of code designed to perform a particular task. It can take inputs, called parameters, and return an output. Functions help organize code, making it easier to read and reuse. For instance, a function named calculateArea could compute the area of a rectangle given its length and width.