Skip to content

Commit 84e44cb

Browse files
authored
Merge pull request #18 from easyawslearn/savan
example updated
2 parents 5994eee + 3b6a5b0 commit 84e44cb

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Diff for: lambda /example1.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1+
## FIND THE SQUARE OF A NUMBER USING LEMBDA FUNCTION
2+
13
square= lambda num: num**2
2-
print(square(8))
4+
print(square(8))
5+
6+
## REVERSE A STRING USING LAMBDA FUNCTION
7+
8+
str = 'hello guys'
9+
# lambda returns a function object
10+
rev_upper = lambda string: string.upper()[::-1]
11+
print(rev_upper(str))
12+
13+
## MAP OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION
14+
15+
mynums=[1,2,3,4,5]
16+
print(list(map(lambda num: num%2==0,mynums)))
17+
18+
## FILTER OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION
19+
mynums=[1,2,3,4,5]
20+
print(list(filter(lambda num: num%2==0,mynums)))
21+
22+
# FIND MAXIMUM NUMBER BETWEEN TWO NUMBERS USING LEMBDA FUNCTION
23+
Max = lambda a, b : a if(a > b) else b
24+
print(Max(8, 4))
25+

0 commit comments

Comments
 (0)