Functions, Arguments, and Recursion in Programming
Classified in Computers
Written on in English with a size of 4.58 KB
Functions and Arguments
A function is a module of program code that takes input (arguments) and produces output (a return value).
- Arguments allow us to customize the operation performed by the function.
- The return value is often the result of executing the code.
- Calling a function causes the code in a function to execute. If called again, it will execute again.
To document a function, use a multi-line comment immediately after the def
line.
Local Variables
Local variables are variables used inside functions.
- They are accessible/usable within that function only.
- This refers to the variable's scope.
Global Variables
Global variables are variables used outside of a function.
- Global variables' scope includes both inside and outside of functions.
- However, since