Examples of Function - 2

Example 1:

add = lambda x,y: x+y
r = add(6,8)
print(r)

14

Example 2:

great = lambda p,q: q if q > p else p
print(great(5,3))

5

Example 3:

fact = lambda num : 1 if num == 1 else num*fact(num-1)
print(fact(int(input("Enter a number : "))))

Enter a number : 34

295232799039604140847618609643520000000

Example 4:

1 2 3 4 5 6 5 3 4

['1', '2', '3', '4', '5', '6', '5', '3', '4']

[1, 2, 3, 4, 5, 6, 5, 3, 4]

Example 6:

1 2 3 4 5 6 7 8 9 10

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 7:

1 2 3 4 5 6 7 8 9 10

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 8:

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

Example 9:

1,2,3,4,5,6,7,8,9

False True False True False True False True False

Example 10:

False True False True False True False True False True

Example 11:

1 3 5 7 9

User Login Authentication:

Login Success

Last updated