ES106 - Module 8-9
ES106 - Module 8-9
ES106 - Module 8-9
PROGRAMMING
FUNCTIONS, PARAMETER PASSING, CALL BY
VALUE, RECURSION, LOCAL AND GLOBAL
VARIABLES
While being incredibly useful for the fields of data science and machine
learning, Python is also great for developing graphical user interfaces. In fact, it
has many frameworks that even beginners can use to easily get started with
developing a GUI.
PYTHON: PARAMETER PASSING
ARGUMENTS
Output: [1, 2, 3, 4]
In the above example, a string which is an immutable type of object is passed as argument
to the function foo. Within the scope of the given function foo, a= “new value” has been
bounded to the same object that string has been bound outside. Within the scope of the function
foo, we modify “old value”` to “new value”. Once we leave the scope of function foo , a=”new
value” is no longer in the name space, and the value that string refers to was never changed.
WHAT IS RECURSION?
Recursion is a common
mathematical and programming
concept. It means that a function
calls itself. This has the benefit of
meaning that you can loop
through data to reach a result.
my_list = [1, 2, 3, 4, 5]
result = sum_list(my_list)
print(result)
Sample Output
The global variables are those which are defined outside any
function, and which are accessible throughout the program.
Sample Output