Python3 max() 関数
説明
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))
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その他の拡張