A function is a self-contained unit of code that performs a specific task and can return a value to the caller.