how to get max value in python code example
Example 1: max int value in python
import sys
MAX_INT = sys.maxsize
print(MAX_INT)
''' NOTE: value of sys.maxsize is depend on the fact that how much bit a machine is. '''
Example 2: python max function
square = {2: 4, -3: 9, -1: 1, -2: 4}
# the largest key
key1 = max(square)
print("The largest key:", key1) # 2
# the key whose value is the largest
key2 = max(square, key = lambda k: square[k])
print("The key with the largest value:", key2) # -3
# getting the largest value
print("The largest value:", square[key2]) # 9