CertGrid CertGrid
Concepts·Certified Associate Python Programmer

Python Lambdas, map() and filter()

PCAP objective 5.2 is embed lambda functions into code. A lambda is a function written as a single expression, with no name and no `return` - the expression *is* the return value. It exists because `sorted`, `map` and `filter` want a small function passed in, and writing a `def` for it is often noise. `map` and `filter` return lazy iterators, and `reduce` is not a built-in at all.

Comprehensions and Lambdas Guide 21 of 25 Intermediate

Written against the versions above. `map` and `filter` return **iterators** in Python 3; in Python 2 they returned lists. `reduce` was moved out of the built-ins into `functools` in Python 3. Both differences appear on this page and both trip up older material.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. A lambda is a function with no name

  2. One expression, and nothing else

  3. A lambda that returns nothing useful

  4. Where lambdas are actually used

  5. map

  6. filter, including the form nobody teaches

  7. map and filter are single-use

  8. reduce, which is not a built-in

  9. reduce without the import

  10. What the exam does with this objective

Official sources