Skip to content

Commit cc4b078

Browse files
committed
example2_added
1 parent 4e778c3 commit cc4b078

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lambda/example2.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add 10 to argument a, and return the result:
2+
x = lambda a : a + 10
3+
print(x(5))
4+
5+
# square of number
6+
squ = lambda num: num**2
7+
print(squ(5))
8+
9+
# Summarize argument a, b, and c and return the result:
10+
x = lambda a, b, c : a + b + c
11+
print(x(5, 6, 2))
12+
13+
14+
# reverse a string with the help of list, map, lamda
15+
fun=["pthon","is","fun"]
16+
ans=(list(map(lambda x:x[::-1],fun)))
17+
print(ans)
18+
19+
# first latter of word of list
20+
name=["python","with","s3cloudehub"]
21+
(print(list(map(lambda n:n[0],name))))
22+
23+
# print even number
24+
mynum=[1,2,3,4,5,6]
25+
print(list(filter(lambda num:num%2==0,mynum)))

0 commit comments

Comments
 (0)