Home > python > Digits of PI (Part 1)

Digits of PI (Part 1)

You want to work with the digits of PI. Why? For instance you want a new job (screenshot here if it got removed since then).

I like simple solutions. So instead of generating the digits, I simply fetched the data from the web. This is a fast, efficient, and painless approach of the problem :) Visit http://newton.ex.ac.uk/research/qsystems/collabs/pi/, where you can download several data files.

For the lazy pigs
I made a script that downloads the data, parses them, and returns the digits as a string. Here it is.

Usage (get the first 30 digits of PI after the dot):

#!/usr/bin/env python

from jabbapylib.math import pi

def main():
    digits = pi.get_digits_of(pi.PI3)    # get 10^3 = 1000 digits
    print digits[:30]

if __name__ == "__main__":



jabbapylib is here

Categories: python Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: