描述
這個max()方法返回其最大參數,即最接近正無窮大的值。
用法
以下是語法max()方法 -
max( x, y, z, .... )
參數
x- 這是一個數字表達式。
y- 這也是一個數字表達式。
z- 這也是一個數字表達式。
返回值
此方法返回最大的參數。
示例
下麵的例子展示了 max() 方法的用法。
#!/usr/bin/python3
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 3 Number min()用法及代碼示例
- Python 3 Number tan()用法及代碼示例
- Python 3 Number atan()用法及代碼示例
- Python 3 Number ceil()用法及代碼示例
- Python 3 Number cos()用法及代碼示例
- Python 3 Number sin()用法及代碼示例
- Python 3 Number round()用法及代碼示例
- Python 3 Number acos()用法及代碼示例
- Python 3 Number shuffle()用法及代碼示例
- Python 3 Number fabs()用法及代碼示例
- Python 3 Number log()用法及代碼示例
- Python 3 Number randrange()用法及代碼示例
- Python 3 Number hypot()用法及代碼示例
- Python 3 Number exp()用法及代碼示例
- Python 3 Number degrees()用法及代碼示例
- Python 3 Number sqrt()用法及代碼示例
- Python 3 Number seed()用法及代碼示例
- Python 3 Number log10()用法及代碼示例
- Python 3 Number radians()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - Number max() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。