Python min() Function

Python 数字Python Numbers


Description

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


Syntax

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

min( x, y, z, .... )

Parameters

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

Return Value

Returns the minimum value of the given parameters.

Example

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

#!/usr/bin/python

print "min(80, 100, 1000) : ", min(80, 100, 1000)
print "min(-20, 100, 400) : ", min(-20, 100, 400)
print "min(-80, -20, -10) : ", min(-80, -20, -10)
print "min(0, 100, -400) : ", min(0, 100, -400)

The output of the above example after running is:

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

Python 数字Python Numbers

Other Extensions