Python3 max() Function

Python3 数字Python3 Numbers


Description

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


Syntax

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

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

Parameters

  • x -- A numeric expression.
  • y -- A numeric expression.
  • z -- A numeric expression.

Return Value

Returns the maximum value of the given parameters.

Example

The following example demonstrates the use of the max() method:

Example

#!/usr/bin/python3

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))

After running the above example, the output result is:

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

Python3 数字Python3 Numbers

Other Extensions