what does max function do in python code example
Example 1: python max function
square = {2: 4, -3: 9, -1: 1, -2: 4}
key1 = max(square)
print("The largest key:", key1)
key2 = max(square, key = lambda k: square[k])
print("The key with the largest value:", key2)
print("The largest value:", square[key2])
Example 2: python max()
i = max(2, 4, 6, 3)
print(i)
Example 3: max func in python
max([2, 1, 4, 3])
Example 4: max in python
print(max(2, 3))
print(max(2, 3, 23))
list1 = [1, 2, 4, 5, 54]
print(max(list1))
Example 5: max function python
max([2, 1, 4, 3])