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
sun_shine
101***0300@qq.com
Python3 参考实例:
测试输出:
sun_shine
101***0300@qq.com
大大大大大大大熊
382***076@qq.com
大大大大大大大熊
382***076@qq.com
kamiya
mec***hui@sina.com
kamiya
mec***hui@sina.com