Skip to content

Integer

In one line

An integer (int) is a whole number without a decimal point, like 42 or -7.

In simple words

An integer is a whole number — positive, negative, or zero — without a fractional part. In Python, the int type has arbitrary precision, meaning integers can be as large as memory allows (no overflow).

You create integers by writing them literally (42), or by converting with int(). Integer arithmetic uses +, -, *, // (floor division), % (modulo), and ** (exponentiation).

Python 3 has only one integer type (int). There is no separate long type — all integers are arbitrary precision. Division with / always returns a float, even for integers; use // for integer division.

Example

python
a = 42
b = -7
c = int("100")

print(a + b)    # 35
print(a // 8)   # 5 (floor division)
print(a % 8)    # 2 (remainder)
print(2 ** 10)  # 1024
print(type(a))  # <class 'int'>

Integers support arithmetic, floor division, modulo, and exponentiation.

Common confusions

  • Confused with: float

    The difference: An integer is a whole number without a decimal point. A float has a decimal point and can represent fractional values. Use int() to convert a float to an integer (truncating toward zero).

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary