How to find the maximum number in python?
Python finds the maximum number. We can use the max() method. The max() method returns the maximum value of the given parameter. The parameter can be a sequence.
The following is the syntax of 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 parameter.
The following shows an example 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)
The output result 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
Related recommendations: "Python Tutorial"
The above is the detailed content of How to find the maximum number in python. For more information, please follow other related articles on the PHP Chinese website!