My first Python program.. Calculating pi geometrically.

Ron Adam radam2 at tampabay.rr.com
Sat Nov 1 13:29:55 EST 2003


On Sat, 01 Nov 2003 12:35:45 +0100, Irmen de Jong
<irmen at -NOSPAM-REMOVETHIS-xs4all.nl> wrote:

>Ron Adam wrote:
>
>> Doing it geometrically was strictly a learning exercise.  And I did
>> learn quite a bit by doing it.
>
>And you only scratched the surface of what Python offers you :-)
>While it's nice to hear that you learned a lot by making this
>arithmetic python program, it certainly is not the most
>inspiring thing that Python is capable of...
>
>I even think you learned more about calculating Pi than you
>did about programming in Python ;-)
>
>--Irmen

The challenging parts were,  figuring out how to do the calculation
without using sin or cos,  (nice geometry refresher), getting the gmpy
module to work and how to set the precision, and working out by trial
and error the precision calculation.   If there is a formula to
convert digits of precision to bits of precision, I'd like to know.
And the last was to figure out how to use the clock and timedelta
functions.

Other interesting things I learned was how to convert to and from
stings,  use slices, and for-in loops are very fast for small lists,
but can eat up a lot of memory, hit the swap file and be extremely
slow for large lists. For-in loops aren't suited for everything. 

And yes, before I started, I did not know how to calculate pi.  So you
are right about that.  ;-)   That was an interesting subject in it
self.

Overall, it was a very good learning project.

_Ron











More information about the Python-list mailing list