FUNCTION– A function is a programming block of codes that is used to perform a single, related task. It only runs when it is called. We can pass data, known as parameters, into a function.
A function can return data as a result. We have already used some python built-in functions like print(), etc. But we can also create our own functions. These functions are called user-defined functions.
Advantages of Using functions:
1.Program development made easy and fast: Work can be divided among project members, thus implementation can be completed fast.
2.Program testing becomes easy : Easy to locate and isolate a faulty function for further investigation
3.Code sharing becomes possible : A function may be used later by many other programs this means that a python programmer can use function written by others, instead of starting over from scratch.
4.Code re-usability increases : A function can be used to keep away from rewriting the same block of codes which we are going use two or more locations in a program. This is especially useful if the code involved is long or complicated.
5.Increases program readability : It makes possible top-down modular programming. In this style of programming, the high-level logic of the overall problem is solved first while the details of each lower-level functions are addressed later. The length of the source program can be reduced by using functions at appropriate places.
6.Function facilitates procedural abstraction : Once a function is written, it serves as a black box. All that a programmer would have to know to invoke a function would be to know its name, and the parameters that it expects
7.Functions facilitate the factoring of code : A function can be called in other function and so on…
——————————————————————————————————————————————