Python | Decimal as_tuple() method Last Updated : 05 Sep, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Decimal#as_tuple() : as_tuple() is a Decimal class method which returns named tuple representation of the Decimal value. Syntax: Decimal.as_tuple() Parameter: Decimal values Return: tuple with values - sign - digits - exponent Code #1 : Example for as_tuple() method Python3 # Python Program explaining # as_tuple() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal(-1) b = Decimal('0.142857') # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.as_tuple() method print ("\n\nDecimal a with as_tuple() method : ", a.as_tuple()) print ("Decimal b with as_tuple() method : ", b.as_tuple()) Output : Decimal value a : -1 Decimal value b : 0.142857 Decimal a with as_tuple() method : DecimalTuple(sign=1, digits=(1, ), exponent=0) Decimal b with as_tuple() method : DecimalTuple(sign=0, digits=(1, 4, 2, 8, 5, 7), exponent=-6) Code #2 : Example for as_tuple() method Python3 # Python Program explaining # as_tuple() method # loading decimal library from decimal import * # Initializing a decimal value a = Decimal('-3.14') b = Decimal('321e + 5') # printing Decimal values print ("Decimal value a : ", a) print ("Decimal value b : ", b) # Using Decimal.as_tuple() method print ("\n\nDecimal a with as_tuple() method : ", a.as_tuple()) print ("Decimal b with as_tuple() method : ", b.as_tuple()) Output : Decimal value a : -3.14 Decimal value b : 3.21E+7 Decimal a with as_tuple() method : DecimalTuple(sign=1, digits=(3, 1, 4), exponent=-2) Decimal b with as_tuple() method : DecimalTuple(sign=0, digits=(3, 2, 1), exponent=5) Comment More infoAdvertise with us Next Article Python | Decimal quantize() method N noobestars101 Follow Improve Article Tags : Python Practice Tags : python Similar Reads Python | Decimal scaleb() method Decimal#scaleb() : scaleb() is a Decimal class method which returns the first operand after adding the second value its exp. Syntax: Decimal.scaleb() Parameter: Decimal values Return: the first operand after adding the second value its exp. Code #1 : Example for scaleb() method Python3 # Python Prog 2 min read Python | Decimal sqrt() method Decimal#sqrt() : sqrt() is a Decimal class method which returns the Square root of a non-negative number to context precision. Syntax: Decimal.sqrt() Parameter: Decimal values Return: the Square root of a non-negative number to context precision. Code #1 : Example for sqrt() method Python3 # Python 2 min read Python | Decimal shift() method Decimal#shift() : shift() is a Decimal class method which returns the shifted copy of x, y times Syntax: Decimal.shift() Parameter: Decimal values Return: the shifted copy of x, y times Code #1 : Example for shift() method Python3 # Python Program explaining # shift() method # loading decimal librar 2 min read Python | Decimal quantize() method decimal module helps you work with numbers that need high precision, like money or scientific calculations. quantize() method is used to round or format a decimal number to a specific number of decimal places while following a chosen rounding rule. For example, let's consider "n = 3.1459", when we a 3 min read Python | Decimal adjusted() method Decimal#adjusted() : adjusted() is a Decimal class method which returns the adjusted exponent after shifting out the coefficientâs rightmost digits until only the lead digit remains Syntax: Decimal.adjusted() Parameter: Decimal values Return: the adjusted exponent after shifting out the coefficientâ 2 min read Python | Decimal copy_abs() method Decimal#copy_abs() : copy_abs() is a Decimal class method which returns the absolute Decimal value. Syntax: Decimal.copy_abs() Parameter: Decimal values Return: the absolute Decimal value Code #1 : Example for copy_abs() method Python3 # Python Program explaining # copy_abs() method # loading decima 2 min read Like