PYTHON
Lecture 5
functions
outlines
• Pass
• Global/local variables
• Keyword arguments
• String formatting
• List comprehension
• Higher order functions
• Lambda
• 2D arrays
• Files and json
Local Variables
Definition: Variables declared inside a function are local to
that function.
Scope: Accessible only within the function where they are
defined.
Global Variables
Definition: Variables declared outside of any function or block
are global variables.
Scope: Accessible throughout the entire program, including
inside functions
Modifying Global Variables
To modify a global variable inside a function, the global keyword
must be used. Without it, Python will treat it as a local variable by
default.
[Link](reverse=True)
Higher order functions
Higher order Callback
Js not python
Anonymous function, lambda
Creating a 2D Array