TensorLearn
Back to Course
Python Essentials: The Engineering Approach
Module 13 of 20

13. Functional Features

Lambda

Anonymous, single-line functions.

python
square = 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.

Mark as Completed

TensorLearn - AI Engineering for Professionals