Python‎ > ‎decimal‎ > ‎

Decimal.as_tuple()


Introduction
Returns with the tuple presentation of the Decimal.

Syntax
Decimal(x).as_tuple()

Parameters
x=Decimal value
as_tuple take no argument

Examples
The method as:
 >>> Decimal(-333).as_tuple()
DecimalTuple(sign=1, digits=(3, 3, 3), exponent=0)
>>>
>>> Decimal(-1).as_tuple()
DecimalTuple(sign=1, digits=(1,), exponent=0)
>>>


input(Decimal().as_tuple())
The method return decimal values in various decimal methods through input() method.
from decimal import Decimal

print("Python Decimal Methods")
a=Decimal(input("Enter Decimal Value: "))

print("Your value in Decimal().adjusted()) method is: ", Decimal(a).adjusted())

print("---------------------------------------------------------------------------------")
print("While other methods return your value as: ")
print("Your value in Decimal().as_tuple(() method is: ", Decimal(a).as_tuple())

print("---------------------------------------------------------------------------------")
print("Your value in Decimal().canonical() method is: ", Decimal(a).canonical())

print("---------------------------------------------------------------------------------")
print("Your value in Decimal().compare(your value-1) method is: ", Decimal(a).compare(a-1))

print("---------------------------------------------------------------------------------")
print("Your value in Decimal().compare_signal(3)) method is: ", Decimal(a).compare_signal(3))

>>> 
Python Decimal Methods
Enter Decimal Value: 55
Your value in Decimal().adjusted()) method is: 1
---------------------------------------------------------------------------------
While other methods return your value as: 
Your value in Decimal().as_tuple(() method is: DecimalTuple(sign=0, digits=(5, 5), exponent=0)
---------------------------------------------------------------------------------
Your value in Decimal().canonical() method is: 55
---------------------------------------------------------------------------------
Your value in Decimal().compare(your value-1) method is: 1
---------------------------------------------------------------------------------
Your value in Decimal().compare_signal(3)) method is: 1
>>>



Comments