Python max() Function

Python 数字Python Numbers


Description

The max() method returns the maximum value of the given parameters, which can be a sequence.


Syntax

The following is the syntax for the max() method:

max( x, y, z, .... )

Parameters

  • x -- Numeric expression.
  • y -- Numeric expression.
  • z -- Numeric expression.

Return Value

Returns the maximum value of the given parameters.

Examples

The following example demonstrates the use of 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)

The output after running the above example is:

max(80, 100, 1000) :  1000
max(-20, 100, 400) :  400
max(-80, -20, -10) :  -10
max(0, 100, -400) :  100

Python 数字Python Numbers

Other Extensions