# max For maximum min For the minimum
print(max([99, 10, 1, 5, 6, 3]))
""" key Usage of parameters : min(*args, key=None): key Is equal to the function name , Note that the function name should not be bracketed ,min Each element of the iteratable object is automatically passed as an argument to key The formal parameters of the function , And then according to key Compare the size of the return value of the function of , The final return is the smallest passed in argument . """
def func(x):
return x[1]
l = [(' Monday ', 300), (' Tuesday ', 200), (' Wednesday ', 99)]
print(min(l, key=func)) # (' Wednesday ', 99)
print(min(l, key=lambda x: func(x))) # (' Wednesday ', 99)
print(min(l, key=lambda x: func(x))[1]) # 99
dic = {
'iphone':5999,'xiaomi':3999, 'oppo':3599}
# By default, the size is compared according to the key , Return key
print(min(dic)) # iphone
# Compare sizes by value , Return key
print(min(dic, key=lambda x:dic[x])) # oppo