Anonymous functions in Python that do not have a name. With the lambda keyword,
little anonymous functions can be created. Anonymous functions are
also called lambda functions by Python programmers. They are part
of the functional paradigm incorporated in Python. Lambda functions are restricted to a single expression.
y = 6
z = lambda x: x * y
print(z(8))
z = lambda x: x * y
print(z(8))
This is a small example of the lambda function.
z = lambda x: x * y
The lambda keyword creates an anonymous function. The x
is a parameter that is passed to the lambda function. The parameter is
followed by a colon character. The code next to the colon is
the expression that is executed, when the lambda function is called.
The lambda function is assigned to the z
variable. cs = [-10, 0, 15, 30, 40]
ft = map(lambda t: (9.0/5)*t + 32, cs)
print(list(ft))
ft = map(lambda t: (9.0/5)*t + 32, cs)
print(list(ft))
No comments:
Post a Comment