Why can a one-line helper like is_even be rewritten as `lambda x: x % 2 == 0` — with no name and no `return` — and when is that actually worth doing?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Create an anonymous (lambda) function that takes one number and returns that number multiplied by itself. Do not use def and do not give the function a name of its own — write it as a lambda and assign that lambda to square.
Functions as objects passed to other functions
Write out the apply function whose first argument is a function name, and record how its body calls criteria(i) and uses that Boolean directly as the if condition.
The four pieces of a lambda expression
Record the lambda keyword, the comma-separated parameters, the colon, and the single expression body, noting the absent return in lambda x: x % 2 == 0.
Calling a lambda inline
Show lambda x: x == 5 handed straight to apply in place of is_5 with the same printed result 1, and (lambda x: x % 2 == 0)(8) as define-and-call in one expression.
Single-use nature of unnamed functions
State that a lambda is never stored in memory under a name, and record that reusing its behavior means writing the whole expression again at each call site.