O'Reilly logo

The Python 3 Standard Library by Example, Second Edition by Doug Hellmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Mathematics

As a general-purpose programming language, Python is frequently used to solve mathematical problems. It includes built-in types for managing integer and floating-point numbers, which are suitable for the basic math that might appear in an average application. The standard library includes modules for more advanced needs.

Python’s built-in floating-point numbers use the underlying double representation. They are sufficiently precise for most programs with mathematical requirements, but when more accurate representations of non-integer values are needed, the decimal (page 239) and fractions (page 250) modules will be useful. Arithmetic with decimal and fractional values retains precision, but is not as fast as the native ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required