What are the max and min values of integer in Python?

Let’s see what the min and max values of an integer are in Python. We will assume we are working on a 64-bit version of Python.

Using the maxsize method

There is a sys module which will help us to answer the above questions. Maxsize method will tell us the max value of integer in Python.

import sys


It turns out the max integer is exactly 9223372036854775807 which is 2^63-1.

See also  How to calculate the exponential value in Python?

However, to display the minimum value, use one of the following:

import sys
minSize = -sys.maxsize - 1


import sys
minSize = ~sys.maxsize

Min value of an integer is -9223372036854775808.