Python max() 函数

Python 教程 · 2019-02-01 21:59:29

描述

max() 方法返回给定参数的最大值,参数可以为序列。

语法

以下是 max() 方法的语法:

max( x, y, z, .... )

参数

  • x -- 数值表达式。
  • y -- 数值表达式。
  • z -- 数值表达式。

返回值

返回给定参数的最大值。

实例

以下展示了使用 max() 方法的实例:

实例(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)

以上实例运行后输出结果为:

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

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

The Lean Startup

The Lean Startup

Eric Ries / Crown Business / 2011-9-13 / USD 26.00

更多中文介绍:http://huing.com Most startups fail. But many of those failures are preventable. The Lean Startup is a new approach being adopted across the globe, chan ging the way companies are built and ......一起来看看 《The Lean Startup》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具