2. Functions
Functions are the subprograms that perform specific task.
Function are the small modules.
A function is a subprogram that act on data and often
returns a value.
4. • Library Functions:
These functions are already built in in the python library. Eg. type( ), len( )
• Functions defined in modules:
These functions defined in particular modules. Whenever we want to use these functions
in program, we need to import the module.
eg. sqrt( ), pow( ) etc.
• User Defined Functions:
These functions are defined by the user.
Prototype:
def function_name(parameters) : // def is a predefine keyword
#Statements
11. Function Parameters
• Formal parameter:
Formal parameter are written in the function prototype and function header of the definition.
• Actual parameter:
When a function is called, the values that are passed in the call are called actual parameters. At
the time of call , each actual parameter is assigned to formal parameter in function definition.
• Default parameter:
Python allows function arguments to have default values. If the function is called without the
argument, the argument gets its default value.
12. Actual and Formal Parameter
* Values being passed are called actual argument
* Values being received are called formal parameter
13.
14.
15.
16.
17.
18. Types of Parameters
• Positional Parameters:
These are the argument passed to a function in correct position order. If we
change their order, then the result will be changed.
19. • Default parameter:
If we are not passing any value , then only default value is considered