Python Getting the Maximum Value
In the following example we use the max() method to find the maximum value:
Example (Python 3.0+)
-- coding: UTF-8 --
Filename : test.py
author by : www.runoob.com
The simplest
(
max
(
1
,
2
)
)
(
max
(
'
a
'
,
'
b
'
)
)
It can also be used on lists and tuples
(
max
(
[
1
,
2
]
)
)
(
max
(
(
1
,
2
)
)
)
More examples
(
"
The maximum of 80, 100, 1000 is:
"
,
max
(
80
,
100
,
1000
)
)
(
"
The maximum of -20, 100, 400 is:
"
,
max
(
20
,
100
,
400
)
)
(
"
The maximum of -80, -20, -10 is:
"
,
max
(
80
, -
20
, -
10
)
)
(
"
The maximum of 0, 100, -400 is:
"
,
max
(
0
,
100
, -
400
)
)
The output of the code above is:
2
b
2
2
80, 100, 1000 最大值为: 1000
-20, 100, 400最大值为: 400
-80, -20, -10最大值为: -10
0, 100, -400最大值为: 100
Introduction to the max() function:Python max()function in Vue 3.
Python3 Examples