data types decimal decimal(" " decimal(' 'decimal numbers are created using the decimal decimal(function this function can take an integer or string argument--but not floatsince floats are held inexactly whereas decimals are represented exactly if string is used it can use simple decimal notation or exponential notation in addition to providing accuracythe exact representation of decimal decimals means that they can be reliably compared for equality from python it is possible to convert floats to decimals using the decimal decimal from_float(function this function takes float as argument and returns the decimal decimal that is closest to the number the float approximates all the numeric operators and functions listed in table ( )including the augmented assignment versionscan be used with decimal decimalsbut with couple of caveats if the *operator has decimal decimal left-hand operandits right-hand operand must be an integer similarlyif the pow(function' first argument is decimal decimalthen its second and optional third arguments must be integers the math and cmath modules are not suitable for use with decimal decimalsbut some of the functions provided by the math module are provided as decimal decimal methods for exampleto calculate ex where is floatwe write math exp( )but where is decimal decimalwe write exp(from the discussion in piece # ( )we can see that exp(isin effectsyntactic sugar for decimal decimal exp(xthe decimal decimal data type also provides ln(which calculates the natural (base elogarithm (just like math log(with one argument)log ()and sqrt()along with many other methods specific to the decimal decimal data type numbers of type decimal decimal work within the scope of contextthe context is collection of settings that affect how decimal decimals behave the context specifies the precision that should be used (the default is decimal places)the rounding techniqueand some other details in some situations the difference in accuracy between floats and decimal decimals becomes obvious print( print(decimal decimal( decimal decimal(" ")