...

/

Creating Anonymous Functions

Creating Anonymous Functions

Learn how to use closures to create anonymous functions.

Anonymous functions

Now we will look at various ways that closures can be used, starting with using closures to create anonymous functions.

A simple introduction to map

The map function is a built-in Python function. In its simplest form, it accepts a function object and a sequence (e.g., a list). It applies the function to each element of the list.

Press + to interact
a = [2.2, 5.6, 1.9, 0.1]
b = map(round, a)
# print(b)
print(list(b)) # [2, 6, 2, 0]

In this example, we ...

Access this course and 1400+ top-rated courses and projects.