Skip to content
AgileLogics
3 min read

Numbers

Prerequisites: Data types

Python has two main numeric types: int for whole numbers with no size limit, and float for numbers with a decimal point.

whole = 42
decimal = 3.14
big = 42_000_000   # underscores are allowed as visual separators

Mixing an int and a float in a calculation always produces a float:

3 + 2.0   # 5.0

Common mistakes

  • Expecting float math to be perfectly exact — 0.1 + 0.2 prints 0.30000000000000004 due to how decimals are stored in binary. This is true of nearly every programming language, not a Python bug.