欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中用max()方法求最大值的介紹

 更新時(shí)間:2015年05月15日 09:35:34   投稿:goldensun  
這篇文章主要介紹了Python中用max()方法求最大值的介紹,是Python入門中的基礎(chǔ)知識(shí),需要的朋友可以參考下

 max() 方法返回其參數(shù)最大值:最接近正無窮大的值。
語法

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

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

參數(shù)

  •     x -- 這是一個(gè)數(shù)值表達(dá)式。
  •     y -- 這也是一個(gè)數(shù)值表達(dá)式。
  •     z -- 這是一個(gè)數(shù)值表達(dá)式。

返回值

此方法返回其參數(shù)的最大值。
例子

下面的例子顯示了max()方法的使用。

#!/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)

當(dāng)我們運(yùn)行上面的程序,它會(huì)產(chǎn)生以下結(jié)果:

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

相關(guān)文章

最新評(píng)論