Python Programming: Ternary operator and lambda function
Ternary operator and the lamda function in Python:
a=int(input("Enter first no "))
b=int(input("Enter second no "))
#Ternary operator used with Lambda function
max=lambda a,b: a if a>b else b
print("Biggest no. ",max(a,b))
#Simply use of ternary operator in Python
print("Smallest no. ", a if a<b else b)
# you can use this type also
min=a if a<b else b
print("Smallest no. ", min)
Comments
Post a Comment