Python‎ > ‎decimal‎ > ‎

Decimal.sqrt()


Definition
Return the square root of the argument to full precision.

Syntax
Decimal(x).sqrt(context=None) 

Parameters
x=Decimal

Examples
The output are:
 >>> Decimal(1).sqrt()
Decimal('1')
>>> Decimal(9.0).sqrt()
Decimal('3')
>>> Decimal(49.0).sqrt()
Decimal('7')
>>> Decimal(1.1).sqrt()
Decimal('1.048808848170151589333698302')
>>> Decimal(.100000).sqrt()
Decimal('0.3162277660168379419769730259')
>>> 


int(Decimal)
The method computed the int(value) of the decimal and then run loop through range() function.
from decimal import Decimal

for i in range(a,10):
    print(i)
    print(i/Decimal(1.1).log10())
        
>>>
0
0E+29
1
24.15885792809678504023429545
2
48.31771585619357008046859090
3
72.47657378429035512070288634
4
96.63543171238714016093718179
5
120.7942896404839252011714772
6
144.9531475685807102414057727
7
169.1120054966774952816400681
8
193.2708634247742803218743636
9
217.4297213528710653621086590
>>>

Comments