FUNCTIONS Functions are the already defined part of the program which can be recalled from other parts of the program as many times as needed. Functions plays an important role in helping to reduce the program code. Function has basic three parts: 1. Function Definition 2. Function Call 3. THE FUNCTION DEFINITION The FUNCTION DEFINATION: The function definition deals with purpose/task of the function. It tells the python what the function does. Syntax: Def function_name(arguments): Function body. Example: Def Add(a,b): Print(a+b) Arguments are the variables used in function. You cannot skip variable name in function definition. THE FUNCTION CALL Function call passes the variable values to function definition, the number of values must match the number of parameters. Syntax: Function_name(values) Example: Add (5,6) Gives output 11 RETURN STATEMENT : Return statement can be used to return function result to function call: Def add(a,b): Return (a+b) Now return sends the value of sum back ...
This Start Code python blog has been created for the beginner to help them learn python.