Answer: look below in explanation
Step-by-step explanation:
For a function, it is needed when it needs to perform a task numerous times in different places at the same time with unique parameters while for a loop, it performs a task multiple times until the loop ends. For a function, mainly it is when we want to change the values and when we want to perform a specific operation whenever we call it. It can be also used to be called at different places to perform operations several times. In a loop, you can't complete the operations until loop finishes and values cannot be changed in loop.