May 2018
Intermediate to advanced
380 pages
9h 37m
English
The fractions module adds support for rational number arithmetic to Python. Rather than using x/y to represent a fraction, true, precise fractions can be written; the former method returns a float type which may or not not be truly accurate.
A constructor is available to create a fraction from integer pairs, from another fraction, a float, a decimal, or a string. If the denominator is 0, a ZeroDivisionError is generated.