September 2026
1051 pages
35h 4m
English
We mentioned floats briefly earlier. Now we’d like to describe in them in greater detail. To store a float with limited precision,[ 38 ] you can use the float data type.
As discussed previously, the literal for a float in the simplest case looks like this:
v = 3.141
The parts before and after the period can be omitted if they have the value 0:
>>> -3. -3.0>>> .0010.001
Note here that the period is an essential element of a float literal and as such must not be omitted.
Since Python 3.6, an underscore can also be used to group the digits of a float literal:
>>> 3.000_000_13.0000001
Python also supports a notation that allows you to use the exponential notation:
v = 3.141e-12
A lowercase ...
Read now
Unlock full access