CHAPTER 2 Flashcards
IN THIS WE WILL LEARN ABOUT FUNCTIONS, SCOPING AND ABSTRACTION.
Define functions.
it is a block of code that is intended to perform related or single operations. it also provides reusability of code and better modularity in application.
call by reference
the original parameter may get updated in case any changes to this parameter are done inside the function
function declaration
def fun_name([arguments]): "optional documentation string" statements
calling a function
calling
it is the same as it is in other languages. it is done by the name of the function along with parameters.
ex: def multi(x,y): z=x*y print("multiplication is ", z) return
multi(1512)
multi(210)
scope of variables
it identifies the part of the program where the particular variable can be accessed.
following are the scope of variable in python:
1. global variables
2. local variables
Recursive Functions
a function can make a call to another function.
when a function calls itself it is known as a recursive function.
Modules
it is a file which contains python definition and statements. the module name is the same as the file name without the suffix .py appended.