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

查看所有标签

How to Think Like a Computer Scientist: Learning with Python

How to Think Like a Computer Scientist: Learning with Python

Allen B. Downey、Jeffrey Elkner、Chris Meyers / Green Tea Press / 2002-1-4 / USD 24.95

""How to Think Like a Computer Scientist"" is an introduction to programming using Python, one of the best languages for beginners. This is a Free Book -- you can download it from thinkpython.com. But......一起来看看 《How to Think Like a Computer Scientist: Learning with Python》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具