title: Pi using Python
body: <p>I am a beginner in Python. I try to evaluate pi in Python Language. I use here the  <a href="http://www.pbs.org/wgbh/nova/archimedes/pi-nf.html" rel="nofollow noreferrer">Archimedes method</a>. </p>
  
  <p>My code is:</p>
  
  <pre><code>import math
  from decimal import *
  getcontext().prec = 50
  
  pi = 0
  PolySides = 6
  SideLen = 1
  Perim = 6
  Dia = 2
  
  while PolySides &lt; 10000000000:
      SideLen2 = Decimal(SideLen) / Decimal(2)
      radius_a = Decimal(math.sqrt(1 - SideLen2**2))
      radius_b = Decimal(1) - Decimal(radius_a)
      SideLenNew = Decimal(math.sqrt(SideLen2**2 + radius_b**2))
      PolyCircum = Decimal(PolySides * SideLen)
      pi = PolyCircum / Dia
      print('Polygon Sides:', PolySides, 'Pi = ', pi)
      SideLen = SideLenNew
      PolySides = 2 * PolySides
  </code></pre>
  
  <p>But for some reason this code prints pi upto 14 decimal places. I cannot understand where I'm  losing precision. Thank you. </p>