Python Exercise Example 49
**Problem:** Use lambda to create an anonymous function.
**Program analysis:** None
Example
#!/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
(
'
The largar one is %d
'
%
MAXIMUM
(
a
,
b
)
)
(
'
The lower one is %d
'
%
MINIMUM
(
a
,
b
)
)
The output of the above example is:
The largar one is 20
The lower one is 10
Python 100 Examples