Home  >  Article  >  Backend Development  >  How to find the maximum number in python

How to find the maximum number in python

藏色散人
藏色散人Original
2019-06-27 11:10:3812630browse

How to find the maximum number in python

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Why is it called Python?Next article:Why is it called Python?