9 lines
303 B
Python
9 lines
303 B
Python
|
import decimal
|
||
|
with decimal.localcontext() as context:
|
||
|
context.prec = 2
|
||
|
print('Local precision:', context.prec)
|
||
|
print('22/7 =', (decimal.Decimal('22') / 7))
|
||
|
|
||
|
print()
|
||
|
print('Default precision:', decimal.getcontext().prec)
|
||
|
print('22 /7 =', (decimal.Decimal('22') / 7))
|