Integer
A whole number with no decimal point, e.g. 42.
An integer (int) is a whole number, positive or negative, with no fractional part. Python integers have unlimited size — they never overflow, so you can compute enormous numbers exactly. Use // for floor (whole-number) division and % for the remainder.
count = 42
print(count + 8) # ordinary arithmetic
print(7 // 2) # floor division -> 3
print(2 ** 100) # exact, no overflow
print(int("100")) # turn a string of digits into an int
Output
50 3 1267650600228229401496703205376 100
Where this shows up in real Python
Whole numbers count things, index into sequences, drive loop ranges, and store money in whole cents to avoid rounding errors.
Commonly used Integer tools
int('42')— turn a string of digits into an inta // b— floor (whole-number) divisiona % b— the remainderabs(n)— distance from zero2 ** 10— exact powers, no overflowdivmod(a, b)— quotient and remainder together
Official documentation: Python Library Reference: Numeric Types — int, float, complex