Latest web development tutorials

Python erhalten maximale Funktion

Document Object Reference Beispiele Python3

Die folgenden Beispiele verwenden wir max () Methode des maximalen Wertes der Auswahl:

# -*- coding: UTF-8 -*-

# Filename : test.py
# author by : www.w3big.com

# 最简单的
print(max(1, 2))
print(max('a', 'b'))
 
# 也可以对列表和元组使用
print(max([1,2]))
print(max((1,2)))

# 更多实例
print("80, 100, 1000 最大值为: ", max(80, 100, 1000))
print("-20, 100, 400最大值为: ", max(-20, 100, 400))
print("-80, -20, -10最大值为: ", max(-80, -20, -10))
print("0, 100, -400最大值为:", max(0, 100, -400))

Führen Sie die oben genannten Code Ausgabeergebnisse:

2
b
2
2
80, 100, 1000 最大值为:  1000
-20, 100, 400最大值为:  400
-80, -20, -10最大值为:  -10
0, 100, -400最大值为: 100

max () Funktionsbeschreibung: die Python max () Funktion.

Document Object Reference Beispiele Python3