Page 5 - LN
P. 5

Lesson Note


               Function with input and a return statement:













               Control flow during program execution
                   1)  Execution always begins with the first statement of the program
                   2)  Comment lines are ignored
                   3)  If program contain def statement, only header of the definition executes, remaining during
                       function call
                   4)  In case of a function call control jumps to function, after execution of function, control
                       jumps back to the function call statement if the function is returning a value else to the line
                       following the function call.
                   5)  A function may contain function inside it, control flow happens accordingly.


               Example of a function definition inside a function:





















               Parameters and Arguments in function
               A parameter is the variable listed inside the parentheses in the function definition. These are values
               required by the function to work. If more than one parameter then they are written as comma
               separated. It has to be a named variable to hold the values.

               An argument is a value that is passed to the function when it is called i.e. Arguments are the values
               provided in function call.
               An argument can be literal/variable/expression and the number of arguments has to be same in
               number as the number of parameters.

               Three types of actual arguments are allowed in Python:
                   1.  Positional arguments
                   2.  Default arguments
                   3.  Keyword arguments
   1   2   3   4   5   6   7   8   9   10