Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
example2_added
  • Loading branch information
norvelp committed Oct 5, 2022
commit cc4b078bda4e14a3bc062f0412423848337ce185
25 changes: 25 additions & 0 deletions lambda/example2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add 10 to argument a, and return the result:
x = lambda a : a + 10
print(x(5))

# square of number
squ = lambda num: num**2
print(squ(5))

# Summarize argument a, b, and c and return the result:
x = lambda a, b, c : a + b + c
print(x(5, 6, 2))


# reverse a string with the help of list, map, lamda
fun=["pthon","is","fun"]
ans=(list(map(lambda x:x[::-1],fun)))
print(ans)

# first latter of word of list
name=["python","with","s3cloudehub"]
(print(list(map(lambda n:n[0],name))))

# print even number
mynum=[1,2,3,4,5,6]
print(list(filter(lambda num:num%2==0,mynum)))