TAB 1 · BEFORE / AFTER
How much shorter?
Click each case to compare a normal def with its lambda form.
Rule: lambda is useful for a short expression used near the call site. Complex logic should stay in
def.WITHOUT LAMBDA
WITH LAMBDA
TAB 2 · SYNTAX
Read it left → right
lambda parameters : expression
- lambda starts the anonymous function.
- parameters receive input.
- : separates input from logic.
- The single expression is returned automatically.
Example
input x → evaluate x * 2 → return result.
lambda x: x * 2input x → evaluate x * 2 → return result.
Your tasks
Complete square, add, PASS/RETRY, and a sorting key.
PYTHON CONSOLE Ready.
TAB 3 · APPLY
Product Processing Pipeline
- filter stock > 0.
- map to (name, price + 7% VAT).
- sorted by VAT price, highest first.
- Print final tuples.
Products
→filter λ
→map λ
→sorted λ
Expected order:
('Monitor', 6313.0)
('Keyboard', 1284.0)
('USB Hub', 952.3)
('Monitor', 6313.0)
('Keyboard', 1284.0)
('USB Hub', 952.3)
PYTHON CONSOLE Ready.