Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python max() function

Python max() function

Python Numbers Python Numbers


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


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

print

"

max(80, 100, 1000) :

"

,

max

(

80

,

100

,

1000

)

print

"

max(-20, 100, 400) :

"

,

max

(

20

,

100

,

400

)

print

"

max(-80, -20, -10) :

"

,

max

(

80

, -

20

, -

10

)

print

"

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 Python Numbers