Back to Course
Python Essentials: The Engineering Approach
Module 13 of 20
13. Functional Features
Lambda
Anonymous, single-line functions.
pythonsquare = lambda x: x * x
Comprehensions
The most "Pythonic" feature. Create lists/dicts in one line.
python# List of squares squares = [x*x for x in range(10) if x % 2 == 0]
This is faster than a for-loop because it runs in C-level speed.