Write Python program to demonstrate ternary operator using tuples, Dictionary and lambda


Topic: Write Python program to demonstrate ternary operator using tuples, Dictionary and lambda

Solution

a, b = 10, 20
print( (b, a) [a < b] ) 
print({True: a, False: b} [a < b]) 
print((lambda: b, lambda: a)[a < b]()) 



List all Python Programs