Python OOPs


Python SQLite


Examples


Others


Lambda Function Python


A lambda function is a single-line anonymous(defined without a name) function, which can take any number of arguments, but it can only have one expression.

Syntax
lambda args : expression

Write a Python program to Square a number using lambda function

Example 1
s=lambda a:a**2
print(s(5))
print(s(10))
Output
25
100

Write a Python program to find greatest of two numbers using lambda function

Example 2
g=lambda a,b: a if a>b else b 
print(g(10,15))
print(g(25,8))
Output
15
25