Mathematics and precise calculations
Python has a decent number of mathematical functions and features built in, but there are cases where you need more advanced features or something faster. In this section, we will discuss a few libraries that help by introducing many extra mathematical functions and/or increase mathematical precision and/or performance quite a bit.
First, let’s discuss the options in the Python core libraries to store numbers and perform calculations with varying precision:
int: To store whole numbers (e.g.1, 2, 3), we have theintobject in Python. Theintis directly translated into a Cint64on most systems as long as it can fit within 64-bit. Outside of that, it is internally cast to a Pythonlongtype (not to be confused with a Clong), which can be arbitrarily large. This allows for infinite accuracy but only works as long as you use whole numbers.fractions.Fraction: TheFractionobject makes it possible to store fractional numbers...