What is printed?
a = 256
b = int('256')
c = 1000
d = int('1000')
print(a is b, c is d)
- True False
- True True
- False False
- False True
CPython caches small integers up to 256, so 256 is reused while 1000 is a fresh object.
Play Problem Solving ▸
a = 256
b = int('256')
c = 1000
d = int('1000')
print(a is b, c is d)