This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions on the go, without assigning them to a variable | |
# Anonymous functions | |
def square(x): | |
return x*x | |
print(square(2)) | |
print((lambda x: x*x)(4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#MAPS | |
def addFive(x): | |
return x + 5 | |
nums = [11,22,33,44,55] | |
result = list(map(addFive,nums)) | |
print(result) | |
nums = [11,22,33,44,55] | |
result = list(map(lambda x:x+5,nums)) | |
print(result) |
NewerOlder