Changes

Jump to: navigation, search

OPS435 Python Lab 4

1 byte removed, 04:41, 13 June 2017
PART 4 - List Comprehension
l2
</source>
:#The above map function requires a function, and a list. This meant that before map() could be used a function needed to be defined earlier in the script. This entire process can be avoided through the use of anonymous functions. This is the ability to create a simple function without defining it, and pass it off for use. Below we will use lambda, which will return a function, and we can use that function immediately. The function takes 1 argument x, and it will perform a single operation on x, square it.<source>
square = lambda x: x ** 2
l1 = [1,2,3,4,5]
198
edits

Navigation menu