unit-3 -functions
unit-3 -functions
52
Function Basics
‘hello’
highorder.py
Functions Inside Functions
funcinfunc.py
Functions Returning Functions
funcreturnfunc.py
Parameters: Defaults
>>> foo()
They are
3
overridden if a
>>> foo(10)
parameter is given 10
default doesn’t
limit the type of a
parameter
Parameters: Named
A lambda
expression >>> f = lambda x,y : x + y
returns a >>> f(2,3)
function object 5
The body can >>> lst = ['one', lambda x : x * x, 3]
only be a simple >>> lst[1](4)
expression, not 16
complex
statements
Modules