Lambda function in Python

 Defining a function in a single line in Python



multiply = lambda a, b : a*b
sum = lambda a, b : a+b
div = lambda a, b : a/b
subt = lambda a, b : a-b
square = lambda a : a**2
cube = lambda a : a**3  
sqrt = lambda a : a**0.5

print(multiply(2, 3))
print(sum(2, 3))
print(div(2, 3))
print(subt(2, 3))
print(square(2))
print(cube(2))
print(sqrt(9))




Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes