A function is a named, independent block of code that performs a specific task. Functions allow programmers to break programs into smaller, reusable pieces of code. A function is defined with a name, parameters, a return type, and a body containing statements. Functions can return values to the code where they were called. Functions make programs more modular and organized.