September 2026
1051 pages
35h 4m
English
The literal for a float consists of a integer part, a decimal point, and a fractional part. As with integers, it’s possible to specify a sign:
>>> 0.50.5>>> -123.456-123.456>>> +1.3371.337
Note that the decimal separator must be a period. A notation with a comma is not permitted. Floats can be used in terms just as intuitively as integers:
>>> 1.5 / 2.10.7142857142857143
It’s also possible to specify a float in scientific notation:
>>> 12.345e312345.0>>> 12.345E312345.0
An expression like XeY represents the number X · 10Y. In the preceeding example it evaluates to 12.345 · 103.
In Part II of the book, we’ll return to these basic data types and cover them in greater detail. Next, we’ll look at another important data type: character ...
Read now
Unlock full access