how to get an exact decimal representation of from decimal import decimal decimal 'decimal(' 'the string here is important if we leave it outwe get decimal that corresponds with the inexact floating point representation of decimal decimal(' 'math you can use the usual math operators to work with decimal objects for exampledecimal decimal decimal(' 'here is another exampledecimal( decimal( decimal(' 'the mathematical functions explnlog and sqrt are methods of decimal objects for instancethe following gives the square root of decimal( sqrt(decimal(' 'decimal objects can also be used with the built in maxminand sum functionsas well as converted to floats with float and strings with str precision by default decimal objects have -digit precision to change it tosayfive digitprecisionuse the getcontext function from decimal import getcontext getcontext(prec here is an example that prints out digits of getcontext(prec decimal( sqrt(decimal(' '