Skip to content

Commit 02894eb

Browse files
authored
Merge pull request #20 from easyawslearn/lamda_ex
Lamda ex
2 parents ae60ba2 + 88d5b5c commit 02894eb

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-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)))
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Local Reassigment!
2+
x=200
3+
print(f"just localy change x to {x}")
4+
5+
# How To Run
6+
# local_ocal_example.py"
7+
# output just localy change x to 200
8+
9+
def myfunc():
10+
x = 300 #local veriabal
11+
print(x)
12+
13+
myfunc()
14+
15+
# How To Run
16+
# local_ocal_example.py"
17+
# output 300

0 commit comments

Comments
 (0)