- Introduction
- Lambda Functions
- map() Function
- filter() Function
- reduce() Function
- Decorators
- List Comprehension
- List Slicing
- Scenario-Based Questions
- Comparison Questions
- Quick Revision
- Final Notes
This document contains the most frequently asked interview questions on Python Functional Programming.
It is useful for:
- Freshers
- Python Developers
- Technical Interviews
- Placement Preparation
- Revision Before Interviews
A lambda function is an anonymous function that consists of a single expression and returns its result automatically.
Because they are created without using the def keyword and usually do not have a function name.
lambda parameters: expressionNo.
A lambda function can contain only one expression.
No.
The expression is returned automatically.
Yes.
Example:
lambda a, b: a + b- map()
- filter()
- reduce()
- sorted()
- max()
- min()
When the logic is complex or requires multiple statements.
map() applies a function to every element of an iterable and returns a map object.
map(function, iterable)A map object.
Yes.
Example:
map(lambda x, y: x + y, list1, list2)Yes.
It accepts both normal functions and lambda functions.
Because map() returns a map object, which is commonly converted into a list for display or further processing.
- List
- Tuple
- Set
- Dictionary
- String
filter() selects elements from an iterable that satisfy a given condition.
A filter object.
A Boolean value (True or False).
Yes.
Lambda functions are commonly used with filter().
Yes.
The element is excluded from the result.
To view or use the filtered elements directly.
reduce() combines all elements of an iterable into a single cumulative value.
functoolsfrom functools import reduceA single cumulative value.
Two arguments.
Yes.
Example:
reduce(function, iterable, initial_value)- Sum
- Product
- Maximum
- Minimum
- String concatenation
A decorator is a function that adds additional functionality to another function without modifying its original code.
To implement reusable features such as:
- Logging
- Authentication
- Validation
- Performance measurement
- Caching
A function that accepts another function as an argument or returns another function.
A nested function inside the decorator that executes additional code before and/or after the original function.
@Yes.
Multiple decorators can be stacked on the same function.
To preserve the metadata of the original function, such as its name and documentation string.
A concise way to create lists using a single line of code.
[expression for item in iterable]Yes.
Example:
[x for x in range(10) if x % 2 == 0]Yes.
- Less code
- Better readability
- Easy transformations
- Efficient list creation
When the logic is too complex and reduces readability.
List slicing extracts a portion of a list using index positions.
list[start:stop:step]No.
The stop index is excluded.
list[::-1]copy = list[:]Yes.
Using slice assignment.
Example:
numbers[1:3] = [100, 200]| map() | filter() |
|---|---|
| Transforms elements | Selects elements |
| Function returns modified value | Function returns Boolean |
| Output size is usually the same | Output size may be smaller |
| filter() | reduce() |
|---|---|
| Returns iterable | Returns one value |
| Selects elements | Combines elements |
| map() | reduce() |
|---|---|
| Returns iterable | Returns one value |
| Transforms values | Aggregates values |
| Lambda | Normal Function |
|---|---|
| Uses lambda keyword | Uses def keyword |
| One expression | Multiple statements allowed |
| Automatic return | Uses return statement |
| List Comprehension | map() |
|---|---|
| Python-specific syntax | Built-in function |
| Easy for simple transformations | Useful when applying existing functions |
| Supports conditions directly | Often combined with filter() |
map()
filter()
reduce()
57. You need to add logging to multiple functions without changing their code. Which Python feature will you use?
Decorators.
List Comprehension.
List Slicing.
list[::-1]Remember:
- Lambda → Anonymous function
- map() → Transform values
- filter() → Select values
- reduce() → Aggregate values
- Decorator → Extend function behavior
- List Comprehension → One-line list creation
- List Slicing → Extract part of a list
@→ Decorator syntax[::-1]→ Reverse list[:]→ Copy list
After completing this chapter, you should be able to:
- Write and use lambda functions.
- Apply map(), filter(), and reduce() appropriately.
- Create reusable decorators.
- Use list comprehensions effectively.
- Perform list slicing operations confidently.
- Answer common Functional Programming interview questions.