A function can access global variables by default but must use the global keyword to modify them. A void function performs an action without returning a value, internally returning None. Formal parameters are defined in the function header while actual parameters are passed in the function call. Example 1 shows a global variable changing within a function while Example 2 demonstrates formal and actual parameters.
A function can access global variables by default but must use the global keyword to modify them. A void function performs an action without returning a value, internally returning None. Formal parameters are defined in the function header while actual parameters are passed in the function call. Example 1 shows a global variable changing within a function while Example 2 demonstrates formal and actual parameters.
A function can access global variables by default but must use the global keyword to modify them. A void function performs an action without returning a value, internally returning None. Formal parameters are defined in the function header while actual parameters are passed in the function call. Example 1 shows a global variable changing within a function while Example 2 demonstrates formal and actual parameters.
• By default we can get the contents of a global variable
inside the body of a function. • But if we want to change a global variable in a function, we must use the global keyword. • If you want the function to be able to modify non-local variables, you must declare them as global in the first line of the function. VOID FUNCTIONS
• A function which performs an action but does not
return a value is called a void function.
• A void function internally returns legal empty value
None. ACTUAL / FORMAL parameters
• The values provided in the brackets of the function
header are called formal parameters. • The values that are passed to the function in the function call statement are called actual parameters. EXAMPLE 1
Explanation : Output is 20 as the global variable has changed within the function. EXAMPLE 2 OUTPUT OF EXAMPLE 2
Excel In 7 Days : Master Excel Features & Formulas. Become A Pro From Scratch In Just 7 Days With Step-By-Step Instructions, Clear Illustrations, And Practical Examples