Python 练习实例49
python 练习实例49
题目:使用lambda来创建匿名函数。
程序分析:无
实例:
#!/usr/bin/python # -*- coding: utf-8 -*- maximum = lambda x,y : (x > y) * x + (x < y) * y minimum = lambda x,y : (x > y) * y + (x < y) * x if __name__ == '__main__': a = 10 b = 20 print ('the largar one is %d' % maximum(a,b)) print ('the lower one is %d' % minimum(a,b))
以上实例输出结果为:
the largar one is 20 the lower one is 10