<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 About arithmetic accuracy in Python
<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Integers" data-toc-modified-id="Integers-1"><span class="toc-item-num">1&nbsp;&nbsp;</span><a href="https
Step1:  Floats
Python uses (hardware) 754 double precision representation for floats. This means that some floats can be only represented approximately.
Using string format to see the precision limitation of doubles in Python. For example, it is impossible to represent exactly the number 0.1
Step2:  This can give us surprises
Step3:  For "infinite" precision float arithmetic you can use decimal or mpmath
Step4:  Getting 30 digits of 1/7
Step5:  We can see how many digits are true of 1/7 using doubles
Step6:  Decimal arithmetic produces decimal objects
Step7:  Decimal objects can be printed with format
Step8:  A more complex example
<ASSISTANT_TASK:>
Python Code:
x = 7**273
print(x)
print(type(x))
Explanation: About arithmetic accuracy in Python
<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Integers" data-toc-modified-id="Integers-1"><span class="toc-item-num">1&nbsp;&nbsp;</span><a href="https://docs.python.org/3/c-api/long.html" target="_blank">Integers</a></a></span></li><li><span><a href="#Floats" data-toc-modified-id="Floats-2"><span class="toc-item-num">2&nbsp;&nbsp;</span><a href="https://docs.python.org/3/tutorial/floatingpoint.html" target="_blank">Floats</a></a></span></li></ul></div>
Integers
In python, integers have arbitrary precision and therefore we can represent an arbitrarily large range of integers (only limited by the available memory).
End of explanation
format(0.1, '.80f')
Explanation: Floats
Python uses (hardware) 754 double precision representation for floats. This means that some floats can be only represented approximately.
Using string format to see the precision limitation of doubles in Python. For example, it is impossible to represent exactly the number 0.1:
End of explanation
.1 + .1 + .1 == .3
.1  + .1 == .2
Explanation: This can give us surprises:
End of explanation
from decimal import Decimal, getcontext
Explanation: For "infinite" precision float arithmetic you can use decimal or mpmath:
End of explanation
getcontext().prec=80
format(Decimal(1)/Decimal(7), '.80f')
Explanation: Getting 30 digits of 1/7:
End of explanation
format(1/7, '.80f')
#12345678901234567 (17 digits)
Explanation: We can see how many digits are true of 1/7 using doubles:
End of explanation
Decimal(1)/Decimal(7)
Explanation: Decimal arithmetic produces decimal objects:
End of explanation
print('{:.50f}'.format(Decimal(1)/Decimal(7)))
Explanation: Decimal objects can be printed with format:
End of explanation
# https://stackoverflow.com/questions/28284996/python-pi-calculation
from decimal import Decimal, getcontext
getcontext().prec=1000
my_pi= sum(1/Decimal(16)**k * 
          (Decimal(4)/(8*k+1) - 
           Decimal(2)/(8*k+4) -
           Decimal(1)/(8*k+5) -
           Decimal(1)/(8*k+6)) for k in range(1000))
'{:.1000f}'.format(my_pi)
Explanation: A more complex example: lets compute 1000 digits of the $\pi$ number using the Bailey–Borwein–Plouffe formula:
$$
\pi = \sum_{k = 0}^{\infty}\Bigg[ \frac{1}{16^k} \left( \frac{4}{8k + 1} - \frac{2}{8k + 4} - \frac{1}{8k + 5} - \frac{1}{8k + 6} \right) \Bigg]
$$
End of explanation
<END_TASK>