How to find the maximum number in python

藏色散人
Release: 2019-08-01 15:51:18
Original
12624 people have browsed it

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, .... )
Copy after login

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)
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!