Python max() function
Description
The max() method returns the maximum of the given arguments, which may be a sequence.
Syntax
The syntax of the max() method is as follows:
max( x, y, z, .... )
Parameters
- x -- a numeric expression.
- y -- a numeric expression.
- z -- a numeric expression.
Return Value
Returns the maximum of the given arguments.
Example
The following shows examples of using the max() method:
Example (Python 2.0+)
#!/usr/bin/python
"
max(80, 100, 1000) :
"
,
max
(
80
,
100
,
1000
)
"
max(-20, 100, 400) :
"
,
max
(
20
,
100
,
400
)
"
max(-80, -20, -10) :
"
,
max
(
80
, -
20
, -
10
)
"
max(0, 100, -400) :
"
,
max
(
0
,
100
, -
400
)
Running the example above produces:
max(80, 100, 1000) : 1000
max(-20, 100, 400) : 400
max(-80, -20, -10) : -10
max(0, 100, -400) : 100
Python Numbers