ECON 3209 · Week 2, Lecture 3 · Kerala Agricultural University
Autumn 2026
By the end of this lecture, you will be able to:
lambdamap() and filter() to economic data examplesfor loop that builds a new objectThink of a comprehension as a fast recipe: “for each district, calculate the new value and store it.”
forif to keep only selected valuesif/else to recode valueszip() lets us walk through several sequences togetherlambda is a short anonymous functionlambda inputs: expressionsorted(), map(), and filter()map() and filter()map() applies a function to every itemfilter() keeps only items where the function returns Truelambdakey= tells sorted() what to compare.sort()Good Python is not the shortest Python — it is the clearest Python that still stays efficient.
A teacher records district-level loan recovery rates: 88, 91, 76, 95, 83.
good_recovery with rates >= 85."strong" or "needs support".sorted(..., key=lambda ...) to sort the original list in descending order.lambda creates short anonymous functions for simple tasksmap(), filter(), and sorted() often pair with lambdasECON 3209 — Kerala Agricultural University