Chapter 15. Lambda functions
Instead of defining the function somewhere and calling it, we can use python's lambda functions, which are inline functions defined at the same place we use it.
They don't need to have a name, so they also called anonymous functions. We define a lambda function using the keyword lambda.
your_function_name = lambda inputs : output
Exercise
l = [2,4,7,3,14,19]
for i in l:
odd_lambda = lambda x : x % 2 != 0
print(odd_lambda(i))
<script.py> output:
False
False
True
True
False
True
'IT World > Python' 카테고리의 다른 글
Python Training Day 12. List Comprehensions (0) | 2022.12.25 |
---|---|
Python Training Day 10 & 11. Pandas Basics, Generators (0) | 2022.12.23 |
Python Training Day 9. Numpy Arrays (0) | 2022.12.20 |
Python Training Day 8. Modules and Packages (0) | 2022.12.19 |
Python Training Day 7. Dictionaries (0) | 2022.12.18 |
댓글