最小值和最大值

基本类型 / 数字 / 数学运算

min_value = min(2, 1, 3)
# min_value is 1

lst = [2, 1, 3]
max_value = max(lst)
# max_value is 3

# Element with the largest len()
words = ["one", "three", "two"]
longest = max(words, key=len)
# longest is 'three'

# Empty list: default instead of ValueError
empty_max = max([], default=0)
# empty_max is 0

print(f"{min_value = }")
print(f"{max_value = }")
print(f"{longest = }")
print(f"{empty_max = }")