float

the data type that represents real numbers

Real numbers are numbers on the number line other than integers, such as -2.5, square root of 2, pi, and so forth.

Python treats integers such as 2, 4, 100, and -42 differently from real numbers. This is even true when we write an integer with a decimal point; that is 100 and 100.0 are treated differently in terms of Python’s “internal processing”, even though they represent the same number.

Python will be precise and exact in representing integers. However, when representing real numbers, even ones that correspond to integers such as 100.0, there is always the potential for some error. This is a consequence of the fact that the number of bits used to represent a number is finite, but the number of real numbers in any range is infinite.

That is:

This error is usually small and insignificant–but not always. It can cause at least two kinds of problems: