A function is a block of code that performs a specific task.
If some functionality is performed at multiple places in software, then rather than writing the same code, again and again, we create a function and call it everywhere. This helps reduce code redundancy.
Functions make maintenance of code easy as we have to change at one place if we make future changes to the functionality.
Functions make the code more readable and easy to understand.